Databricks Delta Lake Tables: Managed vs Unmanaged

VivekR
2 min readApr 10, 2023

--

Managed vs Unmanaged Delta Lake Table

Delta Lake is a powerful storage layer for big data processing workloads in Databricks. In the previous article, we discussed Delta Lake on Databricks: Python Installation and Setup Guide
When working with Delta Lake tables, you can choose between two types of tables: managed and unmanaged. In this article, we’ll explore the key differences between these two types of tables, and how they’re used in Databricks.

Managed Delta Table

Managed Delta Tables are tables whose metadata and data are managed by Delta Lake. You can create a managed Delta table using the SQL API or Python API in Databricks. Managed tables manage the storage and location of data and the table schema. Here’s an example of how to create a managed Delta table using the SQL API:

CREATE TABLE my_table (
id INT,
name STRING
)
USING DELTA;

Unmanaged Delta Table

On the other hand, Unmanaged Delta Tables are tables whose metadata is managed by Delta Lake, but data is managed externally. You can create unmanaged Delta tables using the SQL API or Python API in Databricks. Here’s an example of how to create an unmanaged Delta table using the SQL API:

CREATE TABLE my_table
USING DELTA
LOCATION '/mnt/delta/my_table';

Managed vs Unmanaged Tables

There are several differences between managed and unmanaged tables in Delta Lake. Here are a few key differences:

  • Storage Location: Managed tables are stored in a location managed by Delta Lake, while unmanaged tables are stored in an external location managed by the user.
  • Data Management: Managed tables manage both metadata and data, while unmanaged tables manage only metadata.
  • Schema Management: Both managed and unmanaged tables manage the schema of the table.
  • Performance: Managed tables are generally faster than unmanaged tables because they have better control over the storage and access of the data.
  • Dropping Table: When you drop a managed Delta table, both the table metadata and data are deleted from the storage layer. However, when you drop an unmanaged Delta table, only the table metadata is deleted, and the data remains intact in the external storage layer. Therefore, you need to be careful when dropping unmanaged tables, as you could lose your data if you’re not careful.

In conclusion, Delta Lake tables in Databricks can be managed or unmanaged, and understanding the differences between the two is crucial to optimizing your big data processing workflows. Whether you need the flexibility of unmanaged tables or the power of managed tables, Delta Lake has you covered.

If you found the article to be helpful, you can buy me a coffee here:
Buy Me A Coffee.

--

--

VivekR

Data Engineer, Big Data Enthusiast and Automation using Python