How to Add a Default Value to a Column in Snowflake

Adding a default value to a table column in Snowflake can be tricky. Unfortunately, we can't add a default for an existing column or modify it unless the default value is the sequence.

To modify a default for a column which already contains a sequence default, use the ALTER TABLE <table_name> ALTER <column_name> SET DEFAULT command:

-- example: default id values changed from one sequence to another
alter table products
alter id
set default id_seq.nextval;
database icon
Finally, a unified workspace for your SQL development
Get more done, together, with PopSQL and Snowflake