Snowflake now supports Inline and Out-of-Line Constraints
[ j/n next | k/p prev | g top | r reply | u up ]
Snowflake now supports Inline and Out-of-Line Constraints:
CREATE or replace TABLE customers (
customer_id INTEGER NOT NULL,
customer_name string NOT NULL,
customer_email string check (REGEXP_LIKE(customer_email, '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$') ),
CONSTRAINT email_check check (JAROWINKLER_SIMILARITY(customer_name, split(customer_email, '@')[0]) > 50) ENFORCED
);
insert into customers values (999, 'Saqib Ali', 'saqib@domain.tld'); -- this will work
insert into customers values (999, 'Saqib Ali', 'ali@domain.tld'); -- this will work
insert into customers values (999, 'Saqib Ali', 'uroosa@domain.tld'); -- this will NOT work
insert into customers values (999, 'Saqib Ali', 'saqib/domain.tld'); -- this will NOT work