Clones a source Delta table to a target destination at a specific version. A clone can be either deep or shallow: deep clones copy over the data from the source and shallow clones do not.
There are important differences between shallow and deep clones that can determine how best to use them. See Clone a Delta table.
CREATE TABLE [IF NOT EXISTS] table_name [SHALLOW | DEEP] CLONE source_table_name [LOCATION path]
[CREATE OR] REPLACE TABLE table_name [SHALLOW | DEEP] CLONE source_table_name [LOCATION path]
IF NOT EXISTS
If specified, the statement is ignored if
[CREATE OR] REPLACE
CREATE ORis specified the table is replaced if it exists and newly created if it does not. Without
The name of the Delta Lake table to be created. The name must not include a temporal specification. If the name is not qualified the table is created in the current schema.
table_namemust not exist already unless
IF NOT EXISTShas been specified.
SHALLOW CLONE or DEEP CLONE
If you specify
SHALLOW CLONEDatabricks will make a copy of the source table’s definition, but refer to the source table’s files. When you specify
DEEP CLONE(default) Databricks will make a complete, independent copy of the source table.
The name of the Delta Lake table to be cloned. The name may include a temporal specification.
Optionally creates an external table, with the provided location as the path where the data is stored. If
table_nameitself a path instead of a table identifier, the operation will fail.
pathmust be a STRING literal.
You can use
CREATE TABLE CLONE for complex operations like data migration, data archiving, machine learning flow reproduction, short-term experiments, data sharing, and so on.
See Clone use cases for a few examples.