CREATE TABLE SNAPSHOT
Grammar syntax
CREATE SNAPSHOT TABLE [ IF NOT EXISTS ] table_snapshot_name
CLONE source_table_name
[FOR SYSTEM_TIME AS OF time_expression]
[OPTIONS(snapshot_option_list)]
Sample Source Patterns
General case
The Snapshot keyword is removed in Snowflake, transforming the table into a CREATE TABLE CLONE.
The two differences between snapshot and clones are that snapshots are not editable and usually have an expiration date. Expiration dates are not supported, this is handled as specified for the CREATE TABLE statement unsupported options.
Input Code:
CREATE SNAPSHOT TABLE mytablesnapshot
CLONE mytable;
Output Code:
CREATE TABLE mytablesnapshot CLONE mytable;
FOR SYSTEM TIME AS OF
Input Code:
CREATE SNAPSHOT TABLE IF NOT EXISTS my_snapshot_table2
CLONE some_table_name2
FOR SYSTEM_TIME AS OF TIMESTAMP "2025-01-01 00:00:00 UTC";
Output Code:
CREATE TABLE IF NOT EXISTS my_snapshot_table2
CLONE some_table_name2 AT (TIMESTAMP => TIMESTAMP "2025-01-01 00:00:00 UTC");
Note
The LABELS option in CREATE TABLE COPY statements are not transformed into TAGs because the TAGs of the source table are copied, they cannot be changed during the copy of the table.
Transformation of other table options are the same as specified for the CREATE TABLE statement.
Last updated