Skip to main content

UNDROP DATABASE

The UNDROP DATABASE statement restores a previously dropped MotherDuck database and its snapshot history, as long as the drop is still within the database's snapshot retention window.

This statement applies to MotherDuck native storage databases (standard or transient). DuckLake databases do not support snapshots.

Syntax

UNDROP DATABASE <database_name>

Notes

  • A dropped database can be undropped only while historical snapshots are still retained. The retention period is controlled by SNAPSHOT_RETENTION_DAYS. Use ALTER DATABASE to change it.
  • After undropping, the database is not automatically attached in your current session. Re-attach it with ATTACH 'md:<database_name>', then USE <database_name> if needed.
  • For retention defaults and plan limits, see the data recovery guide and storage lifecycle.

Examples

Drop a database, then undrop and attach it:

DROP DATABASE test_db;
UNDROP DATABASE test_db;
ATTACH 'md:test_db';