TABLE CONSTRAINT

Important Notice: Migration of Documentation Website

Please be advised that our documentation website is currently undergoing a migration to a new platform. To ensure you have access to the most up-to-date information, we kindly request that you visit our new documentation website located at:

Official Snowflake Snowconvert Documentation

For any immediate assistance or if you encounter any issues, please contact our support team at [email protected].

Thank you for your understanding.

Applies to

Some parts in the output code are omitted for clarity reasons.

Description

Specifies the properties of a PRIMARY KEY, FOREIGN KEY, UNIQUE, or CHECK constraint that is part of a new column definition added to a table by using ALTER TABLE. (https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-table-column-constraint-transact-sql)

Translation for column constraints is relatively straightforward. There are several parts of the syntax that are not required or not supported in Snowflake.

These parts include:

  • CLUSTERED | NONCLUSTERED

  • WITH FILLFACTOR = fillfactor

  • WITH ( index_option [, ...n ] )

  • ON { partition_scheme_name ( partition_column_name ) | filegroup | "default" }

  • NOT FOR REPLICATION

  • CHECK [ NOT FOR REPLICATION ]

Syntax in SQL Server

Syntax in Snowflake

Sample Source Patterns

Multiple ALTER TABLE instances

SQL Server

Snowflake

DEFAULT within constraints

SQL Server

Snowflake

Known Issues

1. DEFAULT is only supported within CREATE TABLE and ALTER TABLE ... ADD COLUMN

SQL Server supports defining a DEFAULT property within a constraint, while Snowflake only allows that when adding the column via CREATE TABLE or ALTER TABLE ... ADD COLUMN. DEFAULT properties within the ADD CONSTRAINT syntax are not supported and will be translated to ALTER TABLE ALTER COLUMN.

  1. SSC-EWI-0035: Check statement not supported.

  2. SSC-EWI-0040: Statement Not Supported.

  3. SSC-FDM-TS0020: Default constraint was commented out and may have been added to a table definition.

Last updated