---
sidebar_position: 4
title: Load a DuckDB database into MotherDuck
description: Upload a local DuckDB database file to MotherDuck cloud storage.
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';


MotherDuck supports uploading local DuckDB databases in the cloud as referenced by the [CREATE DATABASE](/sql-reference/motherduck-sql-reference/create-database.md) statement.

<Tabs>
<TabItem value="CLI" label="CLI">

To create a remote database from the current active local database, execute the following command:

```sql
CREATE OR REPLACE DATABASE remote_database_name FROM CURRENT_DATABASE();   
```

To upload an attached local duckdb database, execute the following commands:

```sql
ATTACH '/path/to/local/database.ddb' AS local_db_name;
ATTACH 'md:';
CREATE OR REPLACE DATABASE remote_database_name FROM local_db_name;
```


To upload an duckdb file on disk:

```sql
ATTACH 'md:';
CREATE OR REPLACE DATABASE remote_database_name FROM '/path/to/local/database.ddb';
```

Here's a full end-to-end example:

```sql
-- Let's generate some data based on the tpch extension (will be automatically autoloaded).
-- This will create a couple of tables in the current database.
CALL dbgen(sf=0.1);
-- Connect to MotherDuck
ATTACH 'md:';    
CREATE OR REPLACE DATABASE remote_tpch from CURRENT_DATABASE(); 
```

:::note
Uploading database does not alter context, meaning you are still in the local context after the upload and the query will run locally.
:::

</TabItem>
</Tabs>



---

## 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": "/key-tasks/loading-data-into-motherduck/loading-duckdb-database/",
  "page_title": "Load a DuckDB database into MotherDuck",
  "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.
