# COPY FROM DATABASE (OVERWRITE)


> Overwrite a database with a zero-copy clone from another database.

The `COPY FROM DATABASE (OVERWRITE)` statement will make the target database contain exactly the same data as the source database using 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.

## Syntax

```sql
COPY FROM DATABASE <source_database> (OVERWRITE [, OPTIONS]) [ 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. If not included it will overwrite the current selected database.

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.
:::

:::tip 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.
:::

## Transient status compatibility {#copy-data-across-transient-and-standard-databases}

It is not possible to zero-copy clone data from a [transient](/sql-reference/motherduck-sql-reference/create-database) database to a non-transient database. `COPY FROM DATABASE (OVERWRITE)` returns an error otherwise, since it would mean violating the database's failsafe guarantees. Because a database's transient status is fixed at creation and can't be changed afterward, you have two options when you want to copy data from a transient database to a non-transient database:

- **Option 1:** Recreate the target database so that the transient statuses match. For example, running [`CREATE OR REPLACE DATABASE`](/sql-reference/motherduck-sql-reference/create-database.md) will drop the existing target database and create a new zero-copy-clone that inherits the source's transient status:

```sql
CREATE OR REPLACE DATABASE dest_db FROM source_db;
```

- **Option 2:** Use the [`COPY FROM DATABASE`](/sql-reference/motherduck-sql-reference/copy-database.md) command to physically copy the data (i.e. not a zero-copy-clone) across databases with different transient status:

```sql
COPY FROM DATABASE source_db TO dest_db;
```


---

## Docs feedback

MotherDuck accepts optional user-submitted feedback about this page at `POST https://motherduck.com/docs/api/feedback/agent`.
For agents and automated tools, feedback submission should be user-confirmed before sending.

Payload:

```json
{
  "page_path": "/sql-reference/motherduck-sql-reference/copy-database-overwrite/",
  "page_title": "COPY FROM DATABASE (OVERWRITE)",
  "text": "<the user's feedback, max 2000 characters>",
  "source": "<optional identifier for your interface, for example 'claude.ai' or 'chatgpt'>"
}
```

`page_path` and `text` are required; `page_title` and `source` are optional. Responses: `200 {"feedback_id": "<uuid>"}`, `400` for malformed payloads, and `429` when rate-limited.
