CONSTRAINT DEFINITION

An expression that defines a table constraint

Grammar syntax

constraint_definition:=
[primary_key]
| [[CONSTRAINT constraint_name] foreign_key, ...]

primary_key :=
PRIMARY KEY (column_name[, ...]) NOT ENFORCED

foreign_key :=
FOREIGN KEY (column_name[, ...]) foreign_reference

foreign_reference :=
REFERENCES primary_key_table(column_name[, ...]) NOT ENFORCED

Primary Key Table Constraint

Primary Key is fully supported by Snowflake.

Sample Source

CREATE TABLE table1 (
    col1 integer,
    PRIMARY KEY (col1) NOT ENFORCED
);

CREATE TABLE table2 (
    col1 integer,
    col2 integer,
    PRIMARY KEY (col1, col2) NOT ENFORCED
);

Foreign Key Table Constraint

Foreign Key is fully supported by Snowflake.

Sample Source

CREATE TABLE table1 (
    col1 integer,
    CONSTRAINT fk_col1 FOREIGN KEY (col1) REFERENCES tbl1(col1) NOT ENFORCED
);

Last updated