Create Table

In this section you could find information about TABLES, their syntax and current convertions.

1. Description

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)

Oracle syntax

CREATE [ { GLOBAL | PRIVATE } TEMPORARY | SHARDED | DUPLICATED | [ IMMUTABLE ] BLOCKCHAIN 
  | IMMUTABLE  ] 
   TABLE
  [ schema. ] table
  [ SHARING = { METADATA | DATA | EXTENDED DATA | NONE } ]
  { relational_table | object_table | XMLType_table }
  [ MEMOPTIMIZE FOR READ ]
  [ MEMOPTIMIZE FOR WRITE ]
  [ PARENT [ schema. ] table ] ;

Snowflake Syntax

CREATE [ OR REPLACE ]
    [ { [ { LOCAL | GLOBAL } ] TEMP | TEMPORARY | VOLATILE | TRANSIENT } ]
  TABLE [ IF NOT EXISTS ] <table_name> (
    -- Column definition
    <col_name> <col_type>
      [ inlineConstraint ]
      [ NOT NULL ]
      [ COLLATE '<collation_specification>' ]
      [
        {
          DEFAULT <expr>
          | { AUTOINCREMENT | IDENTITY }
            [
              {
                ( <start_num> , <step_num> )
                | START <num> INCREMENT <num>
              }
            ]
            [ { ORDER | NOORDER } ]
        }
      ]
      [ [ WITH ] MASKING POLICY <policy_name> [ USING ( <col_name> , <cond_col1> , ... ) ] ]
      [ [ WITH ] TAG ( <tag_name> = '<tag_value>' [ , <tag_name> = '<tag_value>' , ... ] ) ]
      [ COMMENT '<string_literal>' ]

    -- Additional column definitions
    [ , <col_name> <col_type> [ ... ] ]

    -- Out-of-line constraints
    [ , outoflineConstraint [ ... ] ]
  )
  [ CLUSTER BY ( <expr> [ , <expr> , ... ] ) ]
  [ ENABLE_SCHEMA_EVOLUTION = { TRUE | FALSE } ]
  [ STAGE_FILE_FORMAT = (
     { FORMAT_NAME = '<file_format_name>'
       | TYPE = { CSV | JSON | AVRO | ORC | PARQUET | XML } [ formatTypeOptions ]
     } ) ]
  [ STAGE_COPY_OPTIONS = ( copyOptions ) ]
  [ DATA_RETENTION_TIME_IN_DAYS = <integer> ]
  [ MAX_DATA_EXTENSION_TIME_IN_DAYS = <integer> ]
  [ CHANGE_TRACKING = { TRUE | FALSE } ]
  [ DEFAULT_DDL_COLLATION = '<collation_specification>' ]
  [ COPY GRANTS ]
  [ COMMENT = '<string_literal>' ]
  [ [ WITH ] ROW ACCESS POLICY <policy_name> ON ( <col_name> [ , <col_name> ... ] ) ]
  [ [ WITH ] TAG ( <tag_name> = '<tag_value>' [ , <tag_name> = '<tag_value>' , ... ] ) ]

For more Snowflake information review the following documentation.

2. Sample Source Patterns

2.1. Physical and Table Properties

Oracle

Snowflake

Table properties are removed because they are not required after the migration in Snowflake.

2.2. Constraints and Constraint States

The following constraints will be commented out:

  • CHECK Constraint

The USING INDEX constraint will be entirely removed from the output code during the conversion.

Oracle

Snowflake

On the other hand, but in the same way, 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.

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.

Oracle

Snowflake

2.3. Foreign Key

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.

Oracle

Snowflake

2.4. Virtual Column

Oracle

Snowflake

2.5. Identity Column

For identity columns, a sequence is created and assigned to the column.

Oracle

Snowflake

2.6. CLOB and BLOB column declaration

Columns declared as CLOB or BLOB will be changed to VARCHAR.

Oracle

Snowflake

2.7. Constraint Name

Oracle

Snowflake

2.8. Default columns with times

The columns declared as Date types will be cast to match with the specific date type.

Oracle

Snowflake

2.9 Sharing and Memoptimize options

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.

Oracle

Snowflake

3. Known Issues

  1. Some properties on the tables may be adapted to or commented on because the behavior in Snowflake is different.

  1. SSC-EWI-0039: Sematic information could not be loaded.

  2. SSC-FDM-0006: Number type column may not behave similarly in Snowflake.

  3. SSC-FDM-0014: Check statement not supported.

  4. SC-FDM-OR0006: Constraint state removed from not null inline constraint.

Last updated