Skip to main content

UNDROP TABLE

Restores the recent version of a dropped table. This leverages the Databend Time Travel feature; a dropped object can be restored only within a retention period (defaults to 24 hours).

See also:

Syntax

UNDROP TABLE [ <database_name>. ]<table_name>

If a table with the same name already exists, an error is returned.

Examples

CREATE TABLE test(a INT, b VARCHAR);

-- drop table
DROP TABLE test;

-- show dropped tables from current database
SHOW TABLES HISTORY;

┌────────────────────────────────────────────────────┐
│ Tables_in_orders_2024 │ drop_time │
├───────────────────────┼────────────────────────────┤
│ test │ 2024-01-23 04:56:34.766820
└────────────────────────────────────────────────────┘

-- restore table
UNDROP TABLE test;
Explore Databend Cloud for FREE
Low-cost
Fast Analytics
Easy Data Ingestion
Elastic Scaling
Try it today