Reference and syntax for the CLONE SQL command.
CREATE TABLE CLONE
operation is extremely fast and highly cost-efficient because it copies the table’s structure and references, without duplicating the actual data.
The column names and data types of the cloned table are automatically inferred from the source table.
Once the clone is created, the cloned table and the source table become independent. Any future changes to the data or schema of either table will not affect the other.
INCLUDING INDEXES
or EXCLUDING INDEXES
options as follows:
Parameter | Description |
---|---|
IF NOT EXISTS | By default, specifies that an existing table <target_table_name> will not be replaced with the new table schema definition. This clause prevents an error message that would otherwise occur, making it useful for scripted and programmatic implementations. |
OR REPLACE | Specifies that an existing <target_table_name> will be replaced with the new table definition. |
<target_table_name> | An identifier that specifies the name of the table. This name should be unique within the target database. |
<source_table_name> | An identifier that specifies the name of the source table to clone. The source table must exist within the source database. |
<index_name> | An aggregating index to clone from the source table, the index must exist and be associated with the source table. |
sales_data
table, including its structure and data:
sales_data
table excluding any of its aggregating indexes:
sales_data
table and includes only the specified only index product_idx
:
sales_data
table and includes all associated indexes:
sales_data
table from the staging
database in the prod
database:
CREATE TABLE CLONE
to clone Firebolt-managed tables. External tables and views are not supported.CREATE TABLE CLONE
is only supported for cloning tables created on Firebolt version 4.10 or higher.