UNDROP DATABASE¶

Restores the most recent version of a dropped database.

See also:

CREATE DATABASE , ALTER DATABASE , DESCRIBE DATABASE , DROP DATABASE , SHOW DATABASES

Syntax¶

UNDROP DATABASE <name>
Copy

Parameters¶

name

Specifies the identifier for the database to restore. If the identifier contains spaces or special characters, the entire string must be enclosed in double quotes. Identifiers enclosed in double quotes are also case-sensitive.

Usage Notes¶

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

  • UNDROP relies on the Snowflake Time Travel feature. An object can be restored only if the object was deleted within the Data Retention Period. The default value is 24 hours.

Examples¶

Restore the most recent version of a dropped database (this example builds on the DROP DATABASE examples):

UNDROP DATABASE mytestdb2;

+-------------------------------------------+
| status                                    |
|-------------------------------------------|
| Database MYTESTDB2 successfully restored. |
+-------------------------------------------+

SHOW DATABASES HISTORY;

+---------------------------------+-----------+------------+------------+--------+--------+---------+---------+----------------+------------+
| created_on                      | name      | is_default | is_current | origin | owner  | comment | options | retention_time | dropped_on |
|---------------------------------+-----------+------------+------------+--------+--------+---------+---------+----------------+------------|
| Tue, 17 Mar 2015 16:57:04 -0700 | MYTESTDB  | N          | Y          |        | PUBLIC |         |         |              1 | [NULL]     |
| Tue, 17 Mar 2015 17:06:32 -0700 | MYTESTDB2 | N          | N          |        | PUBLIC |         |         |              1 | [NULL]     |
| Wed, 25 Feb 2015 17:30:04 -0800 | SALES1    | N          | N          |        | PUBLIC |         |         |              1 | [NULL]     |
| Fri, 13 Feb 2015 19:21:49 -0800 | DEMO1     | N          | N          |        | PUBLIC |         |         |              1 | [NULL]     |
+---------------------------------+-----------+------------+------------+--------+--------+---------+---------+----------------+------------+
Copy