Some parts in the output code are omitted for clarity reasons.
Snowflake supports the grammar for Referential Integrity Constraints, and their properties to facilitate the migration from other databases.
Syntax in SQL Server
Syntax in Snowflake
Sample Source Patterns
SQL Server
Snowflake
Constraints are not enforced in Snowflake, excepting NOT NULL.
Primary and Foreign Key are only used for documentation purposes more than design constraints.
Known Issues
No issues were found
Related EWIs
No related EWIs.
FOREIGN KEY
( column [ ,...n ] )
REFERENCES referenced_table_name [ ( ref_column [ ,...n ] ) ]
[ ON DELETE { NO ACTION | CASCADE | SET NULL | SET DEFAULT } ]
[ ON UPDATE { NO ACTION | CASCADE | SET NULL | SET DEFAULT } ]
[ NOT FOR REPLICATION ]
[ FOREIGN KEY ]
REFERENCES <ref_table_name> [ ( <ref_col_name> ) ]
[ MATCH { FULL | SIMPLE | PARTIAL } ]
[ ON [ UPDATE { CASCADE | SET NULL | SET DEFAULT | RESTRICT | NO ACTION } ]
[ DELETE { CASCADE | SET NULL | SET DEFAULT | RESTRICT | NO ACTION } ] ]
[ [ NOT ] ENFORCED ]
[ [ NOT ] DEFERRABLE ]
[ INITIALLY { DEFERRED | IMMEDIATE } ]
[ ENABLE | DISABLE ]
[ VALIDATE | NOVALIDATE ]
[ RELY | NORELY ]
IN -> SqlServer_01.sql
ALTER TABLE [Tests].[dbo].[Employee]
ADD CONSTRAINT FK_Department FOREIGN KEY(DepartmentID) REFERENCES Department(DepartmentID)
ON UPDATE CASCADE
ON DELETE NO ACTION
NOT FOR REPLICATION;
OUT -> SqlServer_01.sql
ALTER TABLE Tests.dbo.Employee
ADD CONSTRAINT FK_Department FOREIGN KEY(DepartmentID) REFERENCES Department (DepartmentID)
ON UPDATE CASCADE
ON DELETE NO ACTION;