Home > OS >  How to remove not null constraints for multiple columns at a time in snowflake DB
How to remove not null constraints for multiple columns at a time in snowflake DB

Time:12-06

I am not able to drop/ remove not null constraint in snowflake DB

Following things I have tried already...

ALTER TABLE tablename
alter
colname datatype DROP NOT NULL,
ALTER TABLE tablename
alter
colname datatype DROP CONSTRAINT NOT NULL,
ALTER TABLE tablename
modify column
colname datatype DROP CONSTRAINT NOT NULL,
ALTER TABLE tablename
modify column
colname datatype DROP NOT NULL,
ALTER TABLE tablename
DROP CONSTRAINT NOT NULL colname

CodePudding user response:

Datatype is not needed for alter column.

alter table tablename modify column colname DROP NOT NULL;

Doc

CodePudding user response:

Refer to the documentation, there is an example of what you want to do

alter table t1 alter column c1 drop not null;

https://docs.snowflake.com/en/sql-reference/sql/alter-table-column.html#examples

  • Related