Redshift-如何删除NOT NULL约束? [英] Redshift - How to remove NOT NULL constraint?
本文介绍了Redshift-如何删除NOT NULL约束?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
由于Redshift不支持ALTER COLUMN
,所以我想知道是否有可能从Redshift的列中删除NOT NULL约束.
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.
推荐答案
您不能更改表.
有另一种方法.您可以创建一个具有NULL约束的新列.将值从旧列复制到新列,然后删除旧列.
There is an alternative approach. You can create a new column with NULL constraint. Copy the values from your old column to this new column and then drop the old column.
类似这样的东西:
ALTER TABLE table1 ADD COLUMN somecolumn (definition as per your reqm);
UPDATE table1 SET somecolumn = oldcolumn;
ALTER TABLE table1 DROP COLUMN oldcolumn;
ALTER TABLE table1 RENAME COLUMN somecolumn TO oldcolumn;
这篇关于Redshift-如何删除NOT NULL约束?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文