Skip to main content

Load a DuckDB database into MotherDuck

MotherDuck supports uploading local DuckDB databases in the cloud as referenced by the CREATE DATABASE statement.

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

CREATE OR REPLACE DATABASE remote_database_name FROM CURRENT_DATABASE();   

To upload a different local named database, execute the following command :

CREATE OR REPLACE DATABASE remote_database_name FROM '<local database name>';

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

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