CONSTRAINTS

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.

Description

This ensures the accuracy and reliability of the data in the table. If there is any violation between the constraint and the data action, the action is aborted. (Sybase SQL Language Reference)

Grammar Syntax

<table-constraint> ::=
    [ CONSTRAINT <constraint-name> ] 
   {  { UNIQUE | PRIMARY KEY } ( <column-name> [ , … ] )  
     [ IN <dbspace-name> ]
     | <foreign-key-constraint>
     | CHECK ( <condition> )
   }
   
<foreign-key-constraint> ::=
   FOREIGN KEY [ <role-name> ] [ ( <column-name> [ , <column-name> ] … ) ] 
REFERENCES <table-name> [ ( <column-name> [ , <column-name> ] … ) ]
   …[ <actions> ] [ IN <dbspace-name> ]

<actions> ::=
   [ ON { UPDATE | DELETE } RESTRICT ]

Sample Source Patterns

Input Code:

IN -> Sybase_01.sql
CREATE TABLE t_constraint (
    id1 INT NOT NULL,
    id2 INT PRIMARY KEY,
    age INT CHECK (age >= 18),
    email VARCHAR(255) UNIQUE,
    product_id INT REFERENCES products(id) ON DELETE RESTRICT IN SOMEPLACE,
    cod_iq VARCHAR(20) IQ UNIQUE(5),
    CONSTRAINT unq_name_email UNIQUE (name, email),
    CONSTRAINT fk_ord_line FOREIGN KEY (ord_id, line_id) REFERENCES ord_lines(ord_id,line_id)
);

Output Code:

OUT -> Sybase_01.sql
CREATE OR REPLACE TABLE t_constraint (
    id1 INT NOT NULL,
    id2 INT PRIMARY KEY,
    age INT
            !!!RESOLVE EWI!!! /*** SSC-EWI-0035 - CHECK STATEMENT NOT SUPPORTED ***/!!!
            CHECK (age >= 18),
    email VARCHAR(255) UNIQUE,
    product_id INT REFERENCES products (id) ON DELETE RESTRICT ,
    cod_iq VARCHAR(20)
                       !!!RESOLVE EWI!!! /*** SSC-EWI-SY0003 - UNSUPPORTED IQ UNIQUE CONSTRAINT ***/!!!
 IQ UNIQUE(5),
       CONSTRAINT unq_name_email UNIQUE (name, email),
       CONSTRAINT fk_ord_line FOREIGN KEY (ord_id, line_id) REFERENCES ord_lines (ord_id, line_id)
   )
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": {  "major": 0,  "minor": 0,  "patch": "0" }, "attributes": {  "component": "sybase",  "convertedOn": "03/19/2025",  "domain": "test" }}'
;

SSC-EWI-0035: CHECK STATEMENT NOT SUPPORTED.

SSC-EWI-SY0003: UNSUPPORTED IQ UNIQUE CONSTRAINT.

Last updated