Created
February 9, 2025 23:09
-
-
Save HelloNoa/757f8465c763257afc2a2cbf065a5bef to your computer and use it in GitHub Desktop.
postgres 테이블 컬럼 서순 이슈 관련
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 기존 테이블 이름 변경 | |
ALTER TABLE my_table RENAME TO old_my_table; | |
-- 새로운 테이블 생성 (원하는 컬럼 순서로 정의) | |
CREATE TABLE my_table ( | |
col1 INTEGER, | |
col3 TEXT, | |
col2 VARCHAR(50) | |
); | |
-- 데이터 복사 | |
INSERT INTO my_table (col1, col3, col2) | |
SELECT col1, col3, col2 FROM old_my_table; | |
-- 기존 테이블 삭제 (필요 시) | |
DROP TABLE old_my_table; | |
-------------------------------------------------- | |
-- 아니면 이런것도 있음 | |
CREATE VIEW my_table_view AS | |
SELECT col1, col3, col2 | |
FROM my_table; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment