---
title: MotherDuck SQL
description: MotherDuck-specific SQL extensions and cloud database management
---

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](/sql-reference/duckdb-sql-reference) reference.

## Included pages

- [AI Functions](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/ai-functions): MotherDuck AI SQL functions for text generation, embeddings, and SQL assistance.
- [ALTER DATABASE](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/alter-database): Update storage-related settings on a MotherDuck database.
- [ALTER DATABASE SET SNAPSHOT](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/alter-database-snapshot): Restore a database from a snapshot using ALTER DATABASE SET SNAPSHOT TO.
- [ALTER SNAPSHOT](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/alter-snapshot): Rename or remove names from database snapshots using ALTER SNAPSHOT.
- [ATTACH](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/attach): Attach local databases, MotherDuck databases, or public shares to your session
- [COPY FROM DATABASE](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/copy-database): Copy a database from one location to another in MotherDuck
- [COPY FROM DATABASE (OVERWRITE)](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/copy-database-overwrite): Overwrite a database with a zero-copy clone from another database.
- [CREATE DATABASE](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/create-database): Create a database, zero-copy clone from an existing database, or import a local DuckDB file into MotherDuck.
- [CREATE SECRET](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/create-secret): Create a secret in MotherDuck
- [CREATE SHARE](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/create-share): Create a share from a database to share data with other users
- [CREATE SNAPSHOT](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/create-snapshot): Create a snapshot of a MotherDuck database for recovery or read scaling.
- [DESCRIBE SHARE](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/describe-share): Get details about a specific share by name or URL.
- [DETACH](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/detach): Detach local, remote, or shared databases from your session
- [DROP DATABASE](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/drop-database): Remove a database from MotherDuck.
- [DROP SECRET](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/delete-secret): Delete a secret from MotherDuck or local storage.
- [DROP SHARE](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/drop-share): Delete a share and revoke access for all attached users.
- [EXPLAIN](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/explain): Display the physical query plan without executing the query.
- [EXPLAIN ANALYZE](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/explain-analyze): Execute a query and display performance metrics for each operator.
- [GRANT READ ON SHARE](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/grant-access): Give users access to a restricted share.
- [LIST SECRETS](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/list-secrets): List all secrets stored in memory and MotherDuck.
- [LIST SHARES](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/list-shares): List all shares created by the current user.
- [MD_RUN parameter](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/md-run-parameter): Control whether table functions run locally or remotely.
- [PRINT_MD_TOKEN pragma](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/print-md-token): Retrieve your MotherDuck authentication token.
- [REFRESH DATABASE](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/refresh-database): Sync databases with the latest snapshot or share updates.
- [REVOKE READ ON SHARE](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/revoke-access): Remove user access from a restricted share.
- [SHOW ALL DATABASES](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/show-databases): List all MotherDuck, DuckDB, and shared databases.
- [SHUTDOWN](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/shutdown-terminate): Gracefully shut down or force-terminate your Duckling to manage compute costs and recover from stuck queries.
- [TEMPORARY TABLES](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/temporary-tables): Create local temporary tables for session-scoped data.
- [UNDROP DATABASE](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/undrop-database): Restore a dropped MotherDuck database within its snapshot retention window.
- [UPDATE SHARE](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/update-share): Manually update a share with a new database snapshot.
- [Server Connection Management](https://motherduck.com/docs/category/server-connection-management): Managing MotherDuck server connections
- [Introduction to MD_INFORMATION_SCHEMA](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/md_information_schema/introduction): Introduction to MD_INFORMATION_SCHEMA
- [MD_ATTACHED_DATABASES](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/md-attached-databases): List databases attached to your DuckDB and MotherDuck session.
- [MD_LIST_BUCKETS_FOR_SECRET](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/md-list-buckets-for-secret): List S3 buckets visible to a named MotherDuck secret.
- [MD_LIST_FILES](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/md-list-files): List files and folders in S3 and Azure storage from SQL.
- [MD_LIVE_DUCKLING_SIZE](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/md-live-duckling-size): Return the current Duckling instance type for the active MotherDuck connection.
- [MD_USER](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/md-user): Return the current MotherDuck user name.
- [MD_VERSION](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/md-version): Inspect the loaded MotherDuck extension version and build hash.
- [RESULT](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/result): Run a SELECT asynchronously and query its cached results like a table.


---

## 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": "/sql-reference/motherduck-sql-reference/",
  "page_title": "MotherDuck SQL",
  "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.
