2023-04-05 14:49:03 +00:00
---
slug: /en/sql-reference/statements/undrop
sidebar_label: UNDROP
---
# UNDROP TABLE
Cancels the dropping of the table.
2023-04-06 16:09:34 +00:00
Beginning with ClickHouse version 23.3 it is possible to UNDROP a table in an Atomic database
2023-04-06 16:07:00 +00:00
within `database_atomic_delay_before_drop_table_sec` (8 minutes by default) of issuing the DROP TABLE statement. Dropped tables are listed in
2023-04-05 14:49:03 +00:00
a system table called `system.dropped_tables` .
2023-04-06 16:18:09 +00:00
If you have a materialized view without a `TO` clause associated with the dropped table, then you will also have to UNDROP the inner table of that view.
2024-03-20 17:04:35 +00:00
:::note
UNDROP TABLE is experimental. To use it add this setting:
```sql
set allow_experimental_undrop_table_query = 1;
```
:::
2023-04-05 14:49:03 +00:00
:::tip
Also see [DROP TABLE ](/docs/en/sql-reference/statements/drop.md )
:::
Syntax:
``` sql
2023-04-06 16:07:53 +00:00
UNDROP TABLE [db.]name [UUID '< uuid > '] [ON CLUSTER cluster]
2023-04-05 14:49:03 +00:00
```
**Example**
2024-03-20 17:04:35 +00:00
``` sql
set allow_experimental_undrop_table_query = 1;
```
2023-04-05 14:49:03 +00:00
```sql
2024-03-20 17:04:35 +00:00
CREATE TABLE undropMe
2023-04-05 14:49:03 +00:00
(
`id` UInt8
)
ENGINE = MergeTree
2024-03-20 17:04:35 +00:00
ORDER BY id
```
2023-04-05 14:49:03 +00:00
2024-03-20 17:04:35 +00:00
```sql
DROP TABLE undropMe
```
```sql
2023-04-05 14:49:03 +00:00
SELECT *
FROM system.dropped_tables
2024-03-20 17:04:35 +00:00
FORMAT Vertical
2023-04-05 14:49:03 +00:00
```
```response
Row 1:
──────
index: 0
database: default
2024-03-20 17:04:35 +00:00
table: undropMe
2023-04-05 14:49:03 +00:00
uuid: aa696a1a-1d70-4e60-a841-4c80827706cc
engine: MergeTree
2024-03-20 17:04:35 +00:00
metadata_dropped_path: /var/lib/clickhouse/metadata_dropped/default.undropMe.aa696a1a-1d70-4e60-a841-4c80827706cc.sql
2023-04-05 14:49:03 +00:00
table_dropped_time: 2023-04-05 14:12:12
1 row in set. Elapsed: 0.001 sec.
```
```sql
2024-03-20 17:04:35 +00:00
UNDROP TABLE undropMe
```
```response
Ok.
```
```sql
2023-04-05 14:49:03 +00:00
SELECT *
FROM system.dropped_tables
2024-03-20 17:04:35 +00:00
FORMAT Vertical
```
2023-04-05 14:49:03 +00:00
```response
Ok.
0 rows in set. Elapsed: 0.001 sec.
```
```sql
2024-03-20 17:04:35 +00:00
DESCRIBE TABLE undropMe
FORMAT Vertical
2023-04-05 14:49:03 +00:00
```
```response
Row 1:
──────
name: id
type: UInt8
default_type:
default_expression:
comment:
codec_expression:
ttl_expression:
```