In Oracle, the CREATE TABLE statement is used to create one of the following types of tables: a relational table which is the basic structure to hold user data, or an object table which is a table that uses an object type for a column definition. (Oracle documentation)
CREATEORREPLACETABLE"MySchema"."BaseTable"(
BaseId NUMBER(38,18)/*** SSC-FDM-0006 - NUMBER TYPE COLUMN MAY NOT BEHAVE SIMILARLY IN SNOWFLAKE. ***/DEFAULT10NOTNULL)COMMENT='{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},{"attributes":{"component":"oracle"}}';
Note
Table properties are removed because they are not required after the migration in Snowflake.
Snowflake supports CHECK constraints with deterministic, scalar expressions. Oracle-specific state clauses (DEFERRABLE, RELY, INITIALLY, ENABLE, DISABLE) are removed during conversion with SSC-FDM-0046 annotations. CHECK constraints with unsupported expressions (UDFs, non-deterministic functions) are flagged with SSC-EWI-0116.
Supported:
Basic CHECK constraints with scalar, deterministic expressions
CREATEORREPLACETABLE Products (
ProductID NUMBER(38,18)/*** SSC-FDM-0006 - NUMBER TYPE COLUMN MAY NOT BEHAVE SIMILARLY IN SNOWFLAKE. ***/PRIMARYKEY,
Price NUMBER(10,2)/*** SSC-FDM-0006 - NUMBER TYPE COLUMN MAY NOT BEHAVE SIMILARLY IN SNOWFLAKE. ***/CHECK(Price >0),
Quantity NUMBER(38,18)/*** SSC-FDM-0006 - NUMBER TYPE COLUMN MAY NOT BEHAVE SIMILARLY IN SNOWFLAKE. ***/CHECK(Quantity >=0AND Quantity <=1000));
Example 2: CHECK Constraint with NOT DEFERRABLE (Removed)¶
The NOT DEFERRABLE clause is removed with SSC-FDM-0046 because Snowflake always validates CHECK constraints immediately.
CREATEORREPLACETABLEAccounts(
AccountID NUMBER(38,18)/*** SSC-FDM-0006 - NUMBER TYPE COLUMN MAY NOT BEHAVE SIMILARLY IN SNOWFLAKE. ***/PRIMARYKEY,
Balance NUMBER(15,2)/*** SSC-FDM-0006 - NUMBER TYPE COLUMN MAY NOT BEHAVE SIMILARLY IN SNOWFLAKE. ***/--** SSC-FDM-0046 - UNSUPPORTED CHECK CONSTRAINT CLAUSE REMOVED: [NOT] DEFERRABLE **CHECK(Balance >=-1000));
Example 3: CHECK Constraint with RELY Clause (Removed)¶
CREATEORREPLACETABLE Orders (
OrderID NUMBER(38,18)/*** SSC-FDM-0006 - NUMBER TYPE COLUMN MAY NOT BEHAVE SIMILARLY IN SNOWFLAKE. ***/PRIMARYKEY,
TotalAmount NUMBER(10,2)/*** SSC-FDM-0006 - NUMBER TYPE COLUMN MAY NOT BEHAVE SIMILARLY IN SNOWFLAKE. ***/--** SSC-FDM-0046 - UNSUPPORTED CHECK CONSTRAINT CLAUSE REMOVED: [NOT] RELY **CONSTRAINT CHK_Amount CHECK(TotalAmount >0));
Example 4: CHECK Constraint with Unresolved Function (Unsupported)¶
When a CHECK constraint references a function that cannot be resolved, it is flagged with SSC-EWI-0116 as a user-defined function.
CREATEORREPLACETABLE Invoices (
InvoiceID NUMBER(38,18)/*** SSC-FDM-0006 - NUMBER TYPE COLUMN MAY NOT BEHAVE SIMILARLY IN SNOWFLAKE. ***/NOTNULL,
TaxCode VARCHAR(10),CONSTRAINT chk_tax_code
!!!RESOLVE EWI!!!/*** SSC-EWI-0116 - CHECK CONSTRAINT WITH user-defined function IS NOT SUPPORTED IN SNOWFLAKE ***/!!!CHECK(validate_tax_code(TaxCode)=1));
Note
The USING INDEX constraint clause is entirely removed from the output code during the conversion.
In case you have any constraint state after a NOT NULL constraint as follows:
RELY
NO RELY
RELY ENABLE
RELY DISABLE
VALIDATE
NOVALIDATE
These will also be commented out.
Note
The ENABLE constraint state will be completely removed from the output code during the conversion process. In the case of the DISABLE state, it will also be removed concurrently with the NOT NULL constraint.
If there is a table with a NUMBER column with no precision nor scale, and another table with a NUMBER(*,0) column that references to the previously mentioned NUMBER column, we will comment out this foreign key.
CREATEORREPLACETABLE"MySchema"."MyTable"("COL1"NUMBER(38,18)/*** SSC-FDM-0006 - NUMBER TYPE COLUMN MAY NOT BEHAVE SIMILARLY IN SNOWFLAKE. ***/,CONSTRAINT"PK"PRIMARYKEY("COL1"))COMMENT='{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},{"attributes":{"component":"oracle"}}';
CREATEORREPLACETABLE"MySchema"."MyTable"("COL1"NUMBER(38,18)/*** SSC-FDM-0006 - NUMBER TYPE COLUMN MAY NOT BEHAVE SIMILARLY IN SNOWFLAKE. ***/AS(COL1 * COL2))COMMENT='{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},{"attributes":{"component":"oracle"}}';
CREATEORREPLACETABLE"CustomSchema"."BaseTable"("PROPERTY"VARCHAR(64)NOTNULL/*** SSC-FDM-0012 - CONSTRAINT NAME '"MICROSOFT_NN_PROPERTY"' IN NULL OR NOT NULL CONSTRAINT IS NOT SUPPORTED IN SNOWFLAKE ***/)COMMENT='{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},{"attributes":{"component":"oracle"}}';
Some options in Oracle are not required in Snowflake. That is the case for the sharing and memoptimize options, they will be removed in the output code.
CREATEORREPLACETABLE table1 (
id NUMBER(38,18)/*** SSC-FDM-0006 - NUMBER TYPE COLUMN MAY NOT BEHAVE SIMILARLY IN SNOWFLAKE. ***/,nameVARCHAR(50),dateTIMESTAMP/*** SSC-FDM-OR0042 - DATE TYPE COLUMN HAS A DIFFERENT BEHAVIOR IN SNOWFLAKE. ***/,CONSTRAINT pk_table PRIMARYKEY(id))COMMENT='{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},"attributes":{"component":"oracle"}}';
createtable table1
-- NO DROP NO DELETE HASHING USING sha2_512 VERSION v1 -- blockchain_clause not yet supportedDEFAULTCOLLATION somename
ONCOMMITDROP DEFINITION
ONCOMMITDELETEROWSCOMPRESS
NOLOGGING
ASselect*from
table1;
CREATEORREPLACETABLE table1
COMMENT='{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},"attributes":{"component":"oracle"}}'-- NO DROP NO DELETE HASHING USING sha2_512 VERSION v1 -- blockchain_clause not yet supportedASselect*from
table1;