---
sidebar_position: 1
title: UNDROP DATABASE
description: Restore a dropped MotherDuck database within its snapshot retention window.
---

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

```sql
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`](/sql-reference/motherduck-sql-reference/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](/concepts/data-recovery) and [storage lifecycle](/concepts/storage-lifecycle#storage-management).

## Examples

Drop a database, then undrop and attach it:

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