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.
To remove a NOT NULL constraint for a column in MySQL, you use the ALTER TABLE .... MODIFY command and restate the column definition, removing the NOT NULL attribute.
To drop a constraint, specify the constraint name, not the constraint type. To view table constraint names, run the following query. A clause that removes only the specified constraint. RESTRICT is an option for DROP CONSTRAINT.
To remove a NOT NULL constraint for a column in SQL Server, you use the ALTER TABLE .... ALTER COLUMN command and restate the column definition.
You cannot alter the table.
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.
Something like this:
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With