# UNDROP DATABASE
> 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 cannot be restored with `UNDROP DATABASE`; they use their own [snapshot system](/concepts/ducklake#snapshot-retention), which does not support `UNDROP`.

## 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';
```


---

## Docs feedback

MotherDuck accepts optional user-submitted feedback about this page at `GET https://motherduck.com/docs/api/feedback/agent`.
For agents and automated tools, feedback submission should be user-confirmed before sending.

URL-encode query parameter values and send a GET request:

```text
GET https://motherduck.com/docs/api/feedback/agent?page_path=%2Fsql-reference%2Fmotherduck-sql-reference%2Fundrop-database%2F&page_title=UNDROP%20DATABASE&text=<url-encoded user feedback, max 2000 characters>
```

Optionally append `&source=<url-encoded interface identifier>` such as `claude.ai` or `chatgpt`.

`page_path` and `text` are required; `page_title` and `source` are optional. Responses: `200 {"feedback_id": "<uuid>"}`, `400` for malformed query parameters, and `429` when rate-limited.
