Databricks provides the ALTER TABLE ... SET MANAGED command precisely to convert an external Unity Catalog Delta table into a managed table without recreating it. This conversion process minimizes reader and writer downtime (only a brief write-blocking window during the final metadata switch), handles concurrent writes during conversion, and retains the table's existing name, permissions, settings, views, and full history. It also requires that access to the table be name-based (catalog.schema.table) rather than path-based, aligning with Unity Catalog governance. Once converted to a managed table, Unity Catalog automatically handles file cleanup after a DROP TABLE operation (data is marked for deletion, typically reclaimed within about 7-14 days via predictive optimization or VACUUM), unlike external tables where dropping only removes metastore metadata and leaves data files untouched. The alternative approaches fail the requirements: DROP TABLE PURGE destroys the table and its history entirely; ALTER TABLE SET LOCATION merely repoints the external path without changing the table's managed/external type; and CREATE TABLE AS SELECT (CTAS) to a new managed table does not preserve the original name, permissions, or history and introduces additional migration downtime, which is why Databricks explicitly recommends SET MANAGED over CTAS for external-to-managed conversions.
Community Discussion