Search⌘ K
AI Features

Managed Delta Tables with SQL

Explore how to create and manage managed Delta tables using SQL in Databricks. This lesson helps you understand table creation, querying, catalog inspection, and dropping tables with automatic data cleanup. Gain practical skills to organize and maintain Delta tables within the Databricks Lakehouse environment.

Now we will explore how to manage Delta tables. These tables are commonly used in Databricks because they simplify how data is stored and managed.

Managed tables automatically handle the storage location, metadata, and file organization, which makes them easier to work with in production environments.

In the previous lesson, we created a managed Delta table using saveAsTable(). In a managed table, Databricks controls both the table metadata and the underlying data storage. Because the platform manages the storage location automatically, you do not need to specify a file path when creating the table.

Another important characteristic is cleanup: when a managed table is dropped, Databricks automatically deletes the associated data files along with the table metadata.

In this lesson, we will focus on managing and interacting with managed Delta tables using SQL, including querying them, listing available tables, and removing tables when they are no longer needed.

Many organizations manage thousands of Delta tables in the Databricks catalog, and managed tables help keep storage and metadata organized automatically.

Creating a managed Delta table

To demonstrate SQL operations in this lesson, we first create a small managed Delta table. The table will store simple employee sales data that we will query and manage using SQL.

data = [("David", 250), ("Emma", 300)]
columns = ["name", "sales"]
df = spark.createDataFrame(data, columns)
df.write.format("delta").mode("overwrite").saveAsTable("employee_sales")
Creating a managed Delta table named employee_sales
...