Drop schema or catalog using cascade function
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2025 09:01 PM
Hello
In Databricks (non-Unity Catalog), I have two schemas (schema_a and schema_b) that both use the same root location in DBFS or external storage like ADLS.
Example:
abfss://container@storage_account.dfs.core.windows.net/data/project/schema_a
abfss://container@storage_account.dfs.core.windows.net/data/project/schema_b
now, I have dropped schema_a as below: DROP SCHEMA schema_a CASCADE;
Will this remove or affect the tables that belong to schema_b, since both schemas point to the same physical location?
Also, in general, when we drop a schema or catalog using CASCADE, does it delete only objects registered under that schema, or could it potentially delete files or objects in the shared root directory, impacting sibling schemas or unrelated data?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2025 02:15 AM
Hello @EjB
For the given example, here is the response:
Will DROP SCHEMA schema_a CASCADE remove or affect tables in schema_b?
No, unless:
1. The tables in schema_a are managed tables, AND
2. Tables in schema_b store their data physically inside /schema_a/, or
3. Both schemas use a shared storage path
In other words, if a table in schema_b references a path like /schema_a/some_shared_data, or if both schemas store data in a shared directory (e.g., /data/project/shared/), then dropping schema_a may delete those shared files but only if the schema being dropped is managed and owns those files.
For external tables, dropping schema_a will not impact schema_b, even if they share the same root location. This is because dropping external tables only removes the metadata, not the actual files in the storage location.
Hope that helps, let me know if you need to clarify more on this. Best, Ilir