UNDROP SCHEMA
Applies to: Databricks SQL
Databricks Runtime 19 and above
Unity Catalog only
Recovers a dropped schema in Unity Catalog. By default, you can recover a dropped schema for 7 days after the drop. If you configured a custom recovery period on the schema or its catalog, that period applies instead, and recovery ends shortly before the period ends. If the schema was dropped as part of DROP CATALOG ... CASCADE, the catalog's recovery period applies, even if the schema has its own. See Configure the recovery period.
When you specify the schema by name, UNDROP SCHEMA recovers the most recently dropped schema with that name that is still recoverable. To recover a different schema with the same name, use SHOW SCHEMAS DROPPED to find its ID, then run UNDROP SCHEMA WITH ID.
The recovered schema keeps its owner, comment, properties, managed storage location, privilege grants, and tags.
UNDROP SCHEMA recovers only the schema. Tables, volumes, and other objects that were dropped with the schema stay dropped. To recover tables and volumes, run UNDROP TABLE and UNDROP VOLUME after you recover the schema.
While usage of SCHEMA and DATABASE is interchangeable, SCHEMA is preferred.
Syntax
UNDROP { SCHEMA | DATABASE } { schema_name | WITH ID schema_id }
Parameters
-
The name of the dropped schema to recover. You can qualify the name with the catalog name, for example
my_catalog.my_schema. If you don't specify a catalog, the command uses the current catalog. -
schema_idA
STRINGliteral with the UUID of the dropped schema, as shown in theschema_idcolumn of SHOW SCHEMAS DROPPED.
Permissions
To recover a schema, you must meet one of the following requirements:
- Be a metastore admin.
- Be the owner of the parent catalog or have the
MANAGEprivilege on it. - Have the
USE CATALOGandCREATE SCHEMAprivileges on the parent catalog, and be the owner of the dropped schema or have theMANAGEprivilege on it.
If the dropped schema has a managed storage location, you also need the CREATE MANAGED STORAGE privilege on the external location that covers it.
Limitations
- You can recover only schemas in standard Unity Catalog catalogs. You can't recover schemas in foreign catalogs, catalogs created from OpenSharing shares, system catalogs,
hive_metastore, orspark_catalog. - If the parent catalog was dropped, recover it with UNDROP CATALOG before you recover the schema.
- If a schema with the same name already exists in the catalog,
UNDROP SCHEMAfails withUC_UNDROP_RESOURCE_NAME_ALREADY_EXISTS. Rename the existing schema, then run the command again. - A dropped schema that is within its recovery period isn't always recoverable.
UNDROP SCHEMAchecks current conditions, such as resource quotas, conflicts with other managed storage locations, and workspace bindings. The parent catalog must have a read-write binding to the current workspace. If a check fails, resolve the reported error, then run the command again. - If you run
UNDROP SCHEMAbefore Databricks finishes processing the drop, the command fails withUC_UNDROP_RESOURCE_NOT_READY. Wait, then run the command again. - If more than 1,000 schemas in the catalog share the same name, counting the existing schema and all dropped schemas with that name, recovering by name fails. Use
UNDROP SCHEMA WITH IDinstead.
Examples
To recover the most recently dropped schema with a given name, run the following:
> CREATE SCHEMA my_catalog.my_schema;
> DROP SCHEMA my_catalog.my_schema CASCADE;
> UNDROP SCHEMA my_catalog.my_schema;
OK
To recover a specific dropped schema when several share a name, find its ID, then recover it by ID:
> SHOW SCHEMAS DROPPED IN my_catalog;
schema_id schema_name catalog_name deleted_at created_at updated_at created_by owner
------------------------------------ ----------- ------------ ----------------------------- ----------------------------- ----------------------------- ------------- -------------
6ca7be55-8f58-47a7-85ee-7a59082fd17a my_schema my_catalog 2026-10-20 AD at 18:17:56 UTC 2026-10-01 AD at 09:00:00 UTC 2026-10-01 AD at 09:00:00 UTC alf@melmak.et alf@melmak.et
b819f397-c51f-4e60-8acc-05d4d4a7e084 my_schema my_catalog 2026-10-21 AD at 10:20:00 UTC 2026-10-20 AD at 19:00:00 UTC 2026-10-20 AD at 19:00:00 UTC alf@melmak.et alf@melmak.et
-- The schema ID is a string literal, so surround it with single quotation marks.
> UNDROP SCHEMA WITH ID '6ca7be55-8f58-47a7-85ee-7a59082fd17a';
OK
To recover a schema and the tables that were dropped with it, recover the schema first, then each table:
> UNDROP SCHEMA my_catalog.my_schema;
OK
> SHOW TABLES DROPPED IN my_catalog.my_schema;
> UNDROP TABLE my_catalog.my_schema.my_table;
OK