複製 (SQL Analytics)CLONE (SQL Analytics)
ソースデルタテーブルを特定のバージョンのターゲットに複製します。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.
構文Syntax
CREATE TABLE [IF NOT EXISTS] target_table_identifier
[SHALLOW | DEEP] CLONE source_table_identifier [<time_travel_version>]
[LOCATION 'path']
[CREATE OR] REPLACE TABLE target_table_identifier
[SHALLOW | DEEP] CLONE source_table_identifier [<time_travel_version>]
[LOCATION 'path']
- table_identifiertable_identifier
[database_name.] table_name
: テーブル名。必要に応じて、データベース名で修飾します。[database_name.] table_name
: A table name, optionally qualified with a database name.delta.`<path-to-table>`
: 既存のデルタテーブルの場所。delta.`<path-to-table>`
: The location of an existing Delta table.
wherewhere
<time_travel_version> =
TIMESTAMP AS OF timestamp_expression |
VERSION AS OF version
CREATE IF NOT EXISTS
テーブルが既に存在する場合にテーブルを作成しないようにするには、を指定しtarget_table
ます。SpecifyCREATE IF NOT EXISTS
to avoid creating a tabletarget_table
if a table already exists. ターゲットにテーブルが既に存在する場合、複製操作は実行されません。If a table already exists at the target, the clone operation is a no-op.CREATE OR REPLACE
既存のテーブルがある場合に、複製操作の対象を置き換えるには、を指定しtarget_table
ます。SpecifyCREATE OR REPLACE
to replace the target of a clone operation if there is an existing tabletarget_table
. これにより、テーブル名が使用されている場合に、metastore が新しいテーブルで更新されます。This updates the metastore with the new table if table name is used.- またはを指定しない場合は
SHALLOW
DEEP
、ディープクローンが既定で作成されます。If you don’t specifySHALLOW
orDEEP
, a deep clone is created by default. LOCATION
データが格納されるパスとして指定された場所を持つ外部テーブルを作成します。LOCATION
creates an external table, with the provided location as the path where the data is stored. Target がテーブル名ではなくパスの場合、操作は失敗します。If target is a path instead of a table name, the operation will fail.
例Examples
を使用すると、 CLONE
データの移行、データのアーカイブ、機械学習の再現、短期的な実験、データ共有などの複雑な操作を行うことができます。You can use 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.