MotherDuck SQL
MotherDuck extends DuckDB with cloud-native SQL capabilities for managing databases, shares, secrets, and connections. These statements let you work with MotherDuck's serverless infrastructure directly from SQL.
Key capabilities:
- Database management: Create, copy, attach, and drop cloud databases
- Data sharing: Share data with other users and organizations
- Secrets management: Store and manage credentials securely
- AI functions: Generate embeddings, run prompts, and get SQL assistance
- Dives: Create and manage interactive data visualizations
For standard SQL operations, see the DuckDB Syntax reference.
AI
3 items
Dives
11 items
Flights
11 items
MD_INFORMATION_SCHEMA
8 items
Server Connection Management
4 items
ALTER DATABASE
Update storage-related settings on a MotherDuck database.
ALTER DATABASE SET SNAPSHOT
Restore a database from a snapshot using ALTER DATABASE SET SNAPSHOT TO.
ALTER SNAPSHOT
Rename or remove names from database snapshots using ALTER SNAPSHOT.
ATTACH
Attach local databases, MotherDuck databases, or public shares to your session
COPY FROM DATABASE
Copy a database from one location to another in MotherDuck
COPY FROM DATABASE (OVERWRITE)
Overwrite a database with a zero-copy clone from another database.
CREATE DATABASE
Create a database, zero-copy clone from an existing database, or import a local DuckDB file into MotherDuck.
CREATE SECRET
Create a secret in MotherDuck
CREATE SHARE
Create a share from a database to share data with other users
CREATE SNAPSHOT
Create a snapshot of a MotherDuck database for recovery or read scaling.
DESCRIBE SHARE
Get details about a specific share by name or URL.
DETACH
Detach local, remote, or shared databases from your session
DROP DATABASE
Remove a database from MotherDuck.
DROP SECRET
Delete a secret from MotherDuck or local storage.
DROP SHARE
Delete a share and revoke access for all attached users.
EXPLAIN
Display the physical query plan without executing the query.
EXPLAIN ANALYZE
Execute a query and display performance metrics for each operator.
GRANT READ ON SHARE
Give users access to a restricted share.
LIST SECRETS
List all secrets stored in memory and MotherDuck.
LIST SHARES
List all shares created by the current user.
MD_ATTACHED_DATABASES
List databases attached to your DuckDB and MotherDuck session.
MD_LIST_BUCKETS_FOR_SECRET
List S3 buckets visible to a named MotherDuck secret.
MD_LIST_FILES
List files and folders in S3 and Azure storage from SQL.
MD_LIVE_DUCKLING_SIZE
Return the current Duckling instance type for the active MotherDuck connection.
MD_RUN parameter
Control whether table functions run locally or remotely.
MD_USER
Return the current MotherDuck user name.
MD_USER_INFO
Return the current user's ID and name plus the organization's ID, name, plan type, and region.
MD_VERSION
Inspect the loaded MotherDuck extension version and build hash.
PRINT_MD_TOKEN pragma
Retrieve your MotherDuck authentication token.
REFRESH DATABASE
Sync databases with the latest snapshot or share updates.
RESULT
Run a SELECT asynchronously and query its cached results like a table.
REVOKE READ ON SHARE
Remove user access from a restricted share.
SHOW ALL DATABASES
List all MotherDuck, DuckDB, and shared databases.
SHUTDOWN
Gracefully shut down or force-terminate your Duckling to manage compute costs and recover from stuck queries.
TEMPORARY TABLES
Create local temporary tables for session-scoped data.
UNDROP DATABASE
Restore a dropped MotherDuck database within its snapshot retention window.
UPDATE SHARE
Manually update a share with a new database snapshot.