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

