CREATE DATABASE creates a named database in MotherDuck. It does not switch the current session, so run USE afterward or qualify table names with the database name. section 7.3.2
Create, select, and verify a database
CREATE DATABASE "my-test"; SHOW DATABASES; USE my-test; SELECT current_database(); CREATE TABLE people (name varchar, born date); INSERT INTO people VALUES ('Mark', '1989-01-01'), ('Hannes', '1990-01-01'); SELECT count(*) FROM people; section 7.3.2
Use the statement in two practical workflows:
- Create a cloud database directly when source files already reside in public cloud storage, avoiding a local download and re-upload. section 7.3.2
- Upload an existing local DuckDB database with CREATE DATABASE "countries" FROM 'countries.duckdb'; then detach or switch before sharing. section 7.3.1
- Inspect databases with SHOW DATABASES or .databases, and remove a test database after switching away from it with USE and DROP DATABASE. section 7.3.2
.open md: CREATE DATABASE "countries" FROM 'countries.duckdb';
Shows the CLI sequence for attaching MotherDuck and creating a database from a local DuckDB file. section 7.3.1
