Pages

Tuesday, January 14, 2014

Alter the column data type/size on Amazon Redshift

At the time of writing, there is no direct way to alter the column data type or size. However, there is a workaround for this as follows:

ALTER TABLE t ADD COLUMN new_column <correct_column_definition>;UPDATE t SET new_column = old_column;ALTER TABLE t DROP COLUMN old_column;ALTER TABLE t RENAME COLUMN new_column TO old_column;

Please note that following the above procedure will reorder the columns in the table.