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


---

## 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/undrop-database/",
  "page_title": "UNDROP DATABASE",
  "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.
