UNDROP SCHEMA
statementsupportedDatabases & schemasRestore the most recent version of a dropped schema.
Syntax
UNDROP SCHEMA <name>
Parameters
| Name | Required | Description |
|---|---|---|
name | Specifies the identifier for the schema 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
- A schema can only be restored to the database that contained the schema at the time of its deletion. For example, if you create and drop schema s1 in database db1, then change the current database to db2 and attempt to restore schema s1 by ID (or fully-qualified name, db1.s1), schema s1 is restored in database db1 rather than in the current database, db2.
- If a schema 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.
- Hybrid tables that belong to the specified schema are not undropped.
- If you have multiple dropped schemas with the same name, you can use the IDENTIFIER keyword with the system-generated identifier (from the SCHEMATA view) to specify which schema to restore. The name of the restored schema 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.
Access control requirements
A role used to execute this operation must have the following privileges at a minimum: Privilege | Object | Notes CREATE SCHEMA | Database that contained the dropped schema | 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.