COPY FROM DATABASE (OVERWRITE)
The COPY FROM DATABASE ... (OVERWRITE [, OPTIONS]) statement will make the target database contain exactly the same data as the source database via zero-copy cloning, effectively overwriting it.
This command will wait on any ongoing write transactions on the target database to complete, and prevent new ones from starting while it is in progress.
Source Database Options
These additional options can be applied, in addition to OVERWRITE, to specify a specific snapshot of the source database to clone.
| Name | Data Type | Value |
|---|---|---|
| SNAPSHOT_TIME | TIMESTAMP | Selects the newest snapshot created before or at this timestamp |
| SNAPSHOT_ID | UUID | ID of snapshot to clone |
| SNAPSHOT_NAME | STRING | Name of snapshot to clone |
note
This syntax operates at the metadata level and is therefore unique to MotherDuck.
Zero-copy clone
This command operates purely at the MotherDuck metadata layer, so it is a zero-copy clone. The operation is almost instantaneous and does not duplicate any underlying data.
Syntax
COPY FROM DATABASE <source_database> (OVERWRITE) [ TO <target_database> ]
Parameters
<source_database>: The name or path of the source database to copy from, can be either a MotherDuck database or a share.<target_database>: The name or path of the target database to create, must be a MotherDuck database that the user owns.