UNDROP TABLE
statementsupportedTables, views, streams, sequencesRestores the most recent version of a dropped table.
Syntax
UNDROP TABLE <name>
Parameters
| Name | Required | Description |
|---|---|---|
name | Specifies the identifier for the table 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
- Tables can only be restored to the database and schema that contained the table at the time of deletion. For example, if you create and drop table t1 in schema s1, then change the current schema to s2 and attempt to restore table t1 by ID (or qualified name, s1.t1), table t1 is restored in schema s1 rather than in the current schema, s2.
- If a table with the same name already exists, an error is returned.
- If you have multiple dropped tables with the same name, you can use the IDENTIFIER keyword with the system-generated identifier (from the TABLES view) to specify which table to restore. The name of the restored table remains the same. See Examples. Note You can only use the system-generated identifier with the IDENTIFIER() keyword when executing the UNDROP command for notebooks, tables, block storage snapshots, schemas, and databases.
- 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.
- You cannot undrop a hybrid table.
Access control requirements
A role used to execute this operation must have the following privileges at a minimum: Privilege | Object | Notes CREATE TABLE | Schema that contained the dropped table | Operating on an object in a schema requires at least one privilege on the parent database and at least one privilege on the parent schema. For instructions on creating a custom role with a specified set of privileges, see Creating custom roles. For general information about roles and privilege grants for performing SQL actions on securable objects, see Overview of Access Control.