Redshift - How to remove NOT NULL constraint?

后端 未结 3 1389
星月不相逢
星月不相逢 2021-02-12 22:45

Since Redshift does not support ALTER COLUMN, I would like to know if it\'s possible to remove the NOT NULL constraints from columns in Redshift.

3条回答
  •  太阳男子
    2021-02-12 23:08

    There is no way to change column on Redshift.

    I can suggest you to create new column, copy values from old to new column and drop old column.

    ALTER TABLE Table1 ADD COLUMN new_column (___correct_column_definition___);
    UPDATE Table1 SET new_column = column;
    ALTER TABLE Table1 DROP COLUMN column;
    ALTER TABLE Table1 RENAME COLUMN new_column TO column;
    

提交回复
热议问题