-
-
Save zph/9c5be4518842dd9b22eb659890d0ff11 to your computer and use it in GitHub Desktop.
How to change the column type for Redshift.
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
BEGIN; | |
LOCK table_name; | |
ALTER TABLE table_name ADD COLUMN column_new column_type; | |
UPDATE table_name SET column_new = column_name; | |
ALTER TABLE table_name DROP column_name; | |
ALTER TABLE table_name RENAME column_new TO column_name; | |
END; | |
-- varchar -> integer | |
-- UPDATE cpvbeacon_dev SET column_new = CAST (nullif(column_name, '') AS INTEGER); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment