This documentation has been retired and might not be updated. The products, services, or technologies mentioned in this content are no longer supported. See CREATE TABLE CLONE.
Clone a source Delta table to a target destination at a specific version. A clone can be either deep or shallow referring to whether it copies over the data from the source or not.
There are important differences between shallow and deep clones with respect to dependencies between a clone and the source and other differences. See Clone a table on Databricks.
CREATE TABLE [IF NOT EXISTS] [db_name.]target_table [SHALLOW | DEEP] CLONE [db_name.]source_table [<time-travel-version>] [LOCATION 'path']
[CREATE OR] REPLACE TABLE [db_name.]target_table [SHALLOW|DEEP] CLONE [db_name.]source_table [<time-travel-version>] [LOCATION 'path']
<time-travel-version> = TIMESTAMP AS OF timestamp_expression | VERSION AS OF version
CREATE TABLE IF NOT EXISTSto avoid creating a table
target_tableif a table already exists. If a table already exists at the target, the clone operation is a no-op.
CREATE OR REPLACEto replace the target of a clone operation if there is an existing table
target_table. This updates the metastore with the new table if table name is used.
DEEPcreates a shallow or deep clone at the target. If neither
DEEPis specified then a deep clone is created by default.
LOCATIONcreates an external table at the target with the provided location as the path where the data will be stored. If the target provided is a path instead of a table name, the operation will fail.
You can use
CLONE for complex operations like data migration, data archiving, machine learning flow reproduction, short-term experiments, data sharing etc. See Clone a table on Databricks for a few examples.