CREATE TABLE
Description
Creates a new table in the current database. You define a list of columns, which each hold data of a distinct type. The owner of the table is the issuer of the CREATE TABLE command.
For more information, please refer to CREATE TABLE documentation.
Grammar Syntax
--DATASOURCE TABLE
CREATE TABLE [ IF NOT EXISTS ] table_identifier
[ ( col_name1 col_type1 [ COMMENT col_comment1 ], ... ) ]
USING data_source
[ OPTIONS ( key1=val1, key2=val2, ... ) ]
[ PARTITIONED BY ( col_name1, col_name2, ... ) ]
[ CLUSTERED BY ( col_name3, col_name4, ... )
[ SORTED BY ( col_name [ ASC | DESC ], ... ) ]
INTO num_buckets BUCKETS ]
[ LOCATION path ]
[ COMMENT table_comment ]
[ TBLPROPERTIES ( key1=val1, key2=val2, ... ) ]
[ AS select_statement ]
--HIVE FORMAT TABLE
CREATE [ EXTERNAL ] TABLE [ IF NOT EXISTS ] table_identifier
[ ( col_name1[:] col_type1 [ COMMENT col_comment1 ], ... ) ]
[ COMMENT table_comment ]
[ PARTITIONED BY ( col_name2[:] col_type2 [ COMMENT col_comment2 ], ... )
| ( col_name1, col_name2, ... ) ]
[ CLUSTERED BY ( col_name1, col_name2, ...)
[ SORTED BY ( col_name1 [ ASC | DESC ], col_name2 [ ASC | DESC ], ... ) ]
INTO num_buckets BUCKETS ]
[ ROW FORMAT row_format ]
[ STORED AS file_format ]
[ LOCATION path ]
[ TBLPROPERTIES ( key1=val1, key2=val2, ... ) ]
[ AS select_statement ]
--LIKE TABLE
CREATE TABLE [IF NOT EXISTS] table_identifier LIKE source_table_identifier
USING data_source
[ ROW FORMAT row_format ]
[ STORED AS file_format ]
[ TBLPROPERTIES ( key1=val1, key2=val2, ... ) ]
[ LOCATION path ]IF NOT EXISTS
Description
Ensures the table is created only if it does not already exist, preventing duplication and errors in your SQL script.
This syntax is fully supported in Snowflake.
Applies to
Grammar Syntax
Sample Source Patterns
Input Code:
Output Code:
PARTITION BY
Description
Partitions are created on the table, based on the columns specified.
Applies to
Grammar Syntax
Sample Source Patterns
Input Code:
Output Code:
CLUSTERED BY
Description
Partitions created on the table will be bucketed into fixed buckets based on the column specified for bucketing.
This grammar is partially supported
Applies to
Grammar Syntax
The
CLUSTERED BYclause, used for performance optimization, will be converted toCLUSTER BYin Snowflake. Performance may vary between the two architectures.The
SORTED BYclause can be removed during migration, as Snowflake automatically handles data sorting within its micro-partitions.The
INTO BUCKETSclause, a SparkSQL/Databrick specific partitioning setting, should be entirely eliminated, as it's not applicable in Snowflake.
Sample Source Patterns
Input Code:
Output Code:
ROW FORMAT
Description
Specifies the row format for input and output.
This grammar is not supported in Snowflake
Applies to
Grammar Syntax
Sample Source Patterns
Input Code:
Output Code:
STORED AS
Description
File format for table storage.
This grammar is not supported in Snowflake
Applies to
Last updated
