---
title: "Tutorial: Create and manage Delta Lake tables"
description: Create, upsert, read, write, update, delete, display history, query using time travel, optimize, liquid clustering, and clean up operations for Delta Lake tables.
canonical_url: https://docs.databricks.com/aws/en/delta/tutorial
---

# Tutorial: Create and manage Delta Lake tables

This tutorial demonstrates common Delta Lake table operations using sample data. [Delta Lake](https://docs.databricks.com/aws/en/delta/index.md) is the optimized storage layer that provides the foundation for tables on Databricks. Unless otherwise specified, all tables on Databricks are Delta Lake tables.

## Prerequisites

To complete this tutorial, you need:

* Permission to use an existing compute resource or create a new compute resource. See [Compute](https://docs.databricks.com/aws/en/compute/index.md).
* Unity Catalog permissions: `USE CATALOG`, `USE SCHEMA`, and `CREATE TABLE` on the `workspace` catalog. To set these permissions, see your Databricks administrator or [Unity Catalog privileges reference](https://docs.databricks.com/aws/en/data-governance/unity-catalog/access-control/privileges-reference.md).

These examples rely on a dataset called *Synthetic Person Records: 10K to 10M Records*. This dataset contains fictitious records of people, including their first and last names, gender, and age.

First, download the dataset for this tutorial.

1. Visit the [Synthetic Person Records: 10K to 10M Records](https://www.kaggle.com/datasets/swainproject/synthetic-data-person/) page on Kaggle.
2. Click **Download** and then **Download dataset as zip**. This downloads a file named `archive.zip` to your local machine.
3. Extract the `archive` folder from the `archive.zip` file.

Next, upload the `person_10000.csv` dataset to a Unity Catalog [volume](https://docs.databricks.com/aws/en/volumes/index.md) within your Databricks workspace. Databricks recommends uploading your data to a Unity Catalog volume because volumes provide capabilities for accessing, storing, governing, and organizing files.

1. Open Catalog Explorer by clicking ![Data icon.](https://docs.databricks.com/aws/en/images/product-icons/DataIcon.svg) **Catalog** in the sidebar.
2. In Catalog Explorer, click ![Add or plus icon](https://docs.databricks.com/aws/en/images/icons/add-icon.png) **Add data** and **Create a volume**.
3. Name the volume `my-volume` and select **Managed volume** as the volume type.
4. Select the `workspace` catalog and the `default` schema, and then click **Create**.
5. Open `my-volume` and click **Upload to this volume**.
6. Drag and drop or browse to and select the `person_10000.csv` file from within the `archive` folder on your local machine.
7. Click **Upload**.

Last, create a notebook for running the sample code.

1. Click ![Add or plus icon](https://docs.databricks.com/aws/en/images/icons/add-icon.png) **New** in the sidebar.
2. Click ![Notebook icon.](https://docs.databricks.com/aws/en/images/product-icons/NotebookIcon.svg) **Notebook** to create a new notebook.
3. Choose a language for the notebook.

## <a id="create" />Create a table

Create a new Unity Catalog managed table named `workspace.default.people_10k` from `person_10000.csv`. Delta Lake is the default for all table creation, read, and write commands in Databricks.

### Python

```python
from pyspark.sql.types import StructType, StructField, IntegerType, StringType

schema = StructType([
  StructField("id", IntegerType(), True),
  StructField("firstName", StringType(), True),
  StructField("lastName", StringType(), True),
  StructField("gender", StringType(), True),
  StructField("age", IntegerType(), True)
])

df = spark.read.format("csv").option("header", True).schema(schema).load("/Volumes/workspace/default/my-volume/person_10000.csv")

# Create the table if it does not exist. Otherwise, replace the existing table.
df.writeTo("workspace.default.people_10k").createOrReplace()

# If you know the table does not already exist, you can use this command instead.
# df.write.saveAsTable("workspace.default.people_10k")

# View the new table.
df = spark.read.table("workspace.default.people_10k")
display(df)
```

### Scala

```scala
import org.apache.spark.sql.types._

val schema = StructType(Array(
  StructField("id", IntegerType, true),
  StructField("firstName", StringType, true),
  StructField("lastName", StringType, true),
  StructField("gender", StringType, true),
  StructField("age", IntegerType, true)
))

val df = spark.read
  .format("csv")
  .option("header", true)
  .schema(schema)
  .load("/Volumes/workspace/default/my-volume/person_10000.csv")

// Create the table if it does not exist. Otherwise, replace the existing table.
df.writeTo("workspace.default.people_10k").createOrReplace()

// If you know the table does not already exist, you can use this command instead.
// df.saveAsTable("workspace.default.people_10k")

// View the new table.
val df2 = spark.read.table("workspace.default.people_10k")
display(df2)
```

### SQL

```sql
-- Create the table with only the required columns and rename person_id to id.
CREATE OR REPLACE TABLE workspace.default.people_10k AS
SELECT
  person_id AS id,
  firstname,
  lastname,
  gender,
  age
FROM read_files(
  '/Volumes/workspace/default/my-volume/person_10000.csv',
  format => 'csv',
  header => true
);

-- View the new table.
SELECT * FROM workspace.default.people_10k;
```

There are several different ways to create or clone tables. For more information, see [CREATE TABLE](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-create-table.md).

In Databricks Runtime 13.3 LTS and above, you can use [CREATE TABLE LIKE](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-create-table-like.md) to create a new empty Delta Lake table that duplicates the schema and table properties of a source Delta Lake table. This can be useful when promoting tables from a development environment into production.

```sql
CREATE TABLE workspace.default.people_10k_prod LIKE workspace.default.people_10k
```

> [!NOTE]
> **Preview**
>
> This feature is in [Public Preview](https://docs.databricks.com/aws/en/release-notes/release-types.md).

Use the `DeltaTableBuilder` API for [Python](https://docs.delta.io/latest/api/python/spark/index.html) and [Scala](https://docs.delta.io/latest/api/scala/spark/io/delta/tables/DeltaTableBuilder.html) to create an empty table. Compared to `DataFrameWriter` and `DataFrameWriterV2`, the `DeltaTableBuilder` API makes it easier to specify additional information like column comments, table properties, and [generated columns](https://docs.databricks.com/aws/en/tables/features/generated-columns.md).

### Python

```python
from delta.tables import DeltaTable

(
  DeltaTable.createIfNotExists(spark)
    .tableName("workspace.default.people_10k_2")
    .addColumn("id", "INT")
    .addColumn("firstName", "STRING")
    .addColumn("lastName", "STRING", comment="surname")
    .addColumn("gender", "STRING")
    .addColumn("age", "INT")
    .execute()
)

display(spark.read.table("workspace.default.people_10k_2"))
```

### Scala

```scala
import io.delta.tables.DeltaTable

DeltaTable.createOrReplace(spark)
  .tableName("workspace.default.people_10k")
  .addColumn("id", "INT")
  .addColumn("firstName", "STRING")
  .addColumn(
    DeltaTable.columnBuilder("lastName")
      .dataType("STRING")
      .comment("surname")
      .build()
  )
  .addColumn("gender", "STRING")
  .addColumn("age", "INT")
  .execute()

display(spark.read.table("workspace.default.people_10k"))
```

## <a id="upsert" />Upsert to a table

Modify existing records in a table or add new ones using an operation called *upsert*. To merge a set of updates and insertions into an existing Delta Lake table, use the `DeltaTable.merge` method in [Python](https://docs.delta.io/latest/api/python/spark/index.html) and [Scala](https://docs.delta.io/latest/api/scala/spark/io/delta/tables/DeltaTable.html) and the [MERGE INTO](https://docs.databricks.com/aws/en/sql/language-manual/delta-merge-into.md) statement in SQL.

For example, merge data from the source table `people_10k_updates` to the target Delta Lake table `workspace.default.people_10k`. When there is a matching row in both tables, Delta Lake updates the data column using the given expression. When there is no matching row, Delta Lake adds a new row.

### Python

```python
from pyspark.sql.types import StructType, StructField, StringType, IntegerType
from delta.tables import DeltaTable

schema = StructType([
  StructField("id", IntegerType(), True),
  StructField("firstName", StringType(), True),
  StructField("lastName", StringType(), True),
  StructField("gender", StringType(), True),
  StructField("age", IntegerType(), True)
])

data = [
  (10001, 'Billy', 'Luppitt', 'M', 55),
  (10002, 'Mary', 'Smith', 'F', 98),
  (10003, 'Elias', 'Leadbetter', 'M', 48),
  (10004, 'Jane', 'Doe', 'F', 30),
  (10005, 'Joshua', '', 'M', 90),
  (10006, 'Ginger', '', 'F', 16),
]

# Create the source table if it does not exist. Otherwise, replace the existing source table.
people_10k_updates = spark.createDataFrame(data, schema)
people_10k_updates.createOrReplaceTempView("people_10k_updates")

# Merge the source and target tables.
deltaTable = DeltaTable.forName(spark, 'workspace.default.people_10k')

(deltaTable.alias("people_10k")
  .merge(
    people_10k_updates.alias("people_10k_updates"),
    "people_10k.id = people_10k_updates.id")
  .whenMatchedUpdateAll()
  .whenNotMatchedInsertAll()
  .execute()
)

# View the additions to the table.
df = spark.read.table("workspace.default.people_10k")
df_filtered = df.filter(df["id"] >= 10001)
display(df_filtered)
```

### Scala

```scala
import org.apache.spark.sql.types._
import io.delta.tables._

// Define schema
val schema = StructType(Array(
  StructField("id", IntegerType, true),
  StructField("firstName", StringType, true),
  StructField("lastName", StringType, true),
  StructField("gender", StringType, true),
  StructField("age", IntegerType, true)
))

// Create data as Seq of Tuples
val data = Seq(
  (10001, "Billy", "Luppitt", "M", 55),
  (10002, "Mary", "Smith", "F", 98),
  (10003, "Elias", "Leadbetter", "M", 48),
  (10004, "Jane", "Doe", "F", 30),
  (10005, "Joshua", "", "M", 90),
  (10006, "Ginger", "", "F", 16)
)

// Create DataFrame directly from Seq of Tuples
val people_10k_updates = spark.createDataFrame(data).toDF(
  "id", "firstName", "lastName", "gender", "age"
)
people_10k_updates.createOrReplaceTempView("people_10k_updates")

// Merge the source and target tables
val deltaTable = DeltaTable.forName(spark, "workspace.default.people_10k")

deltaTable.as("people_10k")
  .merge(
    people_10k_updates.as("people_10k_updates"),
    "people_10k.id = people_10k_updates.id"
  )
  .whenMatched()
  .updateAll()
  .whenNotMatched()
  .insertAll()
  .execute()

// View the additions to the table.
val df = spark.read.table("workspace.default.people_10k")
val df_filtered = df.filter($"id" >= 10001)
display(df_filtered)
```

### SQL

```sql
-- Create the source table if it does not exist. Otherwise, replace the existing source table.
CREATE OR REPLACE TABLE workspace.default.people_10k_updates(
  id INT,
  firstName STRING,
  lastName STRING,
  gender STRING,
  age INT
);
-- Insert new data into the source table.
INSERT INTO workspace.default.people_10k_updates VALUES
  (10001, "Billy", "Luppitt", "M", 55),
  (10002, "Mary", "Smith", "F", 98),
  (10003, "Elias", "Leadbetter", "M", 48),
  (10004, "Jane", "Doe", "F", 30),
  (10005, "Joshua", "", "M", 90),
  (10006, "Ginger", "", "F", 16);

-- Merge the source and target tables.
MERGE INTO workspace.default.people_10k AS people_10k
USING workspace.default.people_10k_updates AS people_10k_updates
ON people_10k.id = people_10k_updates.id
WHEN MATCHED THEN
  UPDATE SET *
WHEN NOT MATCHED THEN
  INSERT *;

-- View the additions to the table.
SELECT * FROM workspace.default.people_10k WHERE id >= 10001
```

In SQL, the `*` operator updates or inserts all columns in the target table, assuming that the source table has the same columns as the target table. If the target table does not have the same columns, the query throws an analysis error. Also, you must specify a value for every column in your table when you perform an insert operation. The column values can be empty, for example, `''`. When you perform an insert operation, you do not need to update all values.

## <a id="read" />Read a table

Use the table name or path to access data in Delta Lake tables. To access Unity Catalog managed tables, use a fully-qualified table name. Path-based access is only supported for volumes and external tables, not for managed tables. For more information, see [Path rules and access in Unity Catalog volumes](https://docs.databricks.com/aws/en/volumes/paths.md).

### Python

```python
people_df = spark.read.table("workspace.default.people_10k")
display(people_df)
```

### Scala

```scala
val people_df = spark.read.table("workspace.default.people_10k")
display(people_df)
```

### SQL

```sql
SELECT * FROM workspace.default.people_10k;
```

## <a id="write" />Write to a table

Delta Lake uses the standard syntax for writing data to tables. To add new data to an existing Delta Lake table, use the append mode. Unlike upserting, writing to a table does not check for duplicate records.

### Python

```python
from pyspark.sql.types import StructType, StructField, StringType, IntegerType
from pyspark.sql.functions import col

schema = StructType([
  StructField("id", IntegerType(), True),
  StructField("firstName", StringType(), True),
  StructField("lastName", StringType(), True),
  StructField("gender", StringType(), True),
  StructField("age", IntegerType(), True)
])

data = [
  (10007, 'Miku', 'Hatsune', 'F', 25)
]

# Create the new data.
df  = spark.createDataFrame(data, schema)

# Append the new data to the target table.
df.write.mode("append").saveAsTable("workspace.default.people_10k")

# View the new addition.
df = spark.read.table("workspace.default.people_10k")
df_filtered = df.filter(df["id"] == 10007)
display(df_filtered)
```

### Scala

```scala
// Create the new data.
val data = Seq(
  (10007, "Miku", "Hatsune", "F", 25)
)

val df = spark.createDataFrame(data)
  .toDF("id", "firstName", "lastName", "gender", "age")

// Append the new data to the target table
df.write.mode("append").saveAsTable("workspace.default.people_10k")

// View the new addition.
val df2 = spark.read.table("workspace.default.people_10k")
val df_filtered = df2.filter($"id" === 10007)
display(df_filtered)
```

### SQL

```sql
CREATE OR REPLACE TABLE workspace.default.people_10k_new (
  id INT,
  firstName STRING,
  lastName STRING,
  gender STRING,
  age INT
);

-- Insert the new data.
INSERT INTO workspace.default.people_10k_new VALUES
  (10007, 'Miku', 'Hatsune', 'F', 25);

-- Append the new data to the target table.
INSERT INTO workspace.default.people_10k
SELECT * FROM workspace.default.people_10k_new;

-- View the new addition.
SELECT * FROM workspace.default.people_10k WHERE id = 10007;
```

Databricks notebook cell outputs display a maximum of 10,000 rows or 2 MB, whichever is lower. Because `workspace.default.people_10k` contains more than 10,000 rows, only the first 10,000 rows appear in the notebook output for `display(df)`. The additional rows are present in the table, but are not rendered in the notebook output due to this limit. You can view the additional rows by specifically filtering for them.

To replace all the data in a table, use the overwrite mode.

### Python

```python
df.write.mode("overwrite").saveAsTable("workspace.default.people_10k")
```

### Scala

```scala
df.write.mode("overwrite").saveAsTable("workspace.default.people_10k")
```

### SQL

```sql
INSERT OVERWRITE TABLE workspace.default.people_10k SELECT * FROM workspace.default.people_10k_2
```

## <a id="update" />Update a table

Update data in a Delta Lake table based on a predicate. For example, change the values in the `gender` column from `Female` to `F`, from `Male` to `M`, and from `Other` to `O`.

### Python

```python
from delta.tables import *
from pyspark.sql.functions import *

deltaTable = DeltaTable.forName(spark, "workspace.default.people_10k")

# Declare the predicate and update rows using a SQL-formatted string.
deltaTable.update(
  condition = "gender = 'Female'",
  set = { "gender": "'F'" }
)

# Declare the predicate and update rows using Spark SQL functions.
deltaTable.update(
  condition = col('gender') == 'Male',
  set = { 'gender': lit('M') }
)

deltaTable.update(
  condition = col('gender') == 'Other',
  set = { 'gender': lit('O') }
)

# View the updated table.
df = spark.read.table("workspace.default.people_10k")
display(df)
```

### Scala

```scala
import io.delta.tables._
import org.apache.spark.sql.functions._

val deltaTable = DeltaTable.forName(spark, "workspace.default.people_10k")

// Declare the predicate and update rows using a SQL-formatted string.
deltaTable.updateExpr(
  "gender = 'Female'",
  Map("gender" -> "'F'")
)

// Declare the predicate and update rows using Spark SQL functions.
deltaTable.update(
  col("gender") === "Male",
  Map("gender" -> lit("M")));

deltaTable.update(
  col("gender") === "Other",
  Map("gender" -> lit("O")));

// View the updated table.
val df = spark.read.table("workspace.default.people_10k")
display(df)
```

### SQL

```sql
-- Declare the predicate and update rows.
UPDATE workspace.default.people_10k SET gender = 'F' WHERE gender = 'Female';
UPDATE workspace.default.people_10k SET gender = 'M' WHERE gender = 'Male';
UPDATE workspace.default.people_10k SET gender = 'O' WHERE gender = 'Other';

-- View the updated table.
SELECT * FROM workspace.default.people_10k;
```

## <a id="delete" />Delete from a table

Remove data that matches a predicate from a Delta Lake table. For example, the code below demonstrates two delete operations: first deleting rows where age is less than 18, then deleting rows where age is less than 21.

### Python

```python
from delta.tables import *
from pyspark.sql.functions import *

deltaTable = DeltaTable.forName(spark, "workspace.default.people_10k")

# Declare the predicate and delete rows using a SQL-formatted string.
deltaTable.delete("age < '18'")

# Declare the predicate and delete rows using Spark SQL functions.
deltaTable.delete(col('age') < '21')

# View the updated table.
df = spark.read.table("workspace.default.people_10k")
display(df)
```

### Scala

```scala
import io.delta.tables._
import org.apache.spark.sql.functions._

val deltaTable = DeltaTable.forName(spark, "workspace.default.people_10k")

// Declare the predicate and delete rows using a SQL-formatted string.
deltaTable.delete("age < '18'")

// Declare the predicate and delete rows using Spark SQL functions.
deltaTable.delete(col("age") < "21")

// View the updated table.
val df = spark.read.table("workspace.default.people_10k")
display(df)
```

### SQL

```sql
-- Delete rows using a predicate.
DELETE FROM workspace.default.people_10k WHERE age < '21';

-- View the updated table.
SELECT * FROM workspace.default.people_10k;
```

> [!IMPORTANT]
>
> Deletion removes the data from the latest version of the Delta Lake table but does not remove it from physical storage until the old versions are explicitly vacuumed. For more information, see [vacuum](https://docs.databricks.com/aws/en/tables/operations/vacuum.md).

## <a id="display-history" />Display table history

Use the `DeltaTable.history` method in [Python](https://docs.delta.io/latest/api/python/spark/index.html) and [Scala](https://docs.delta.io/latest/api/scala/spark/io/delta/tables/DeltaTable.html) and the [DESCRIBE HISTORY](https://docs.databricks.com/aws/en/tables/history.md) statement in SQL to view the provenance information for each write to a table.

### Python

```python
from delta.tables import *

deltaTable = DeltaTable.forName(spark, "workspace.default.people_10k")
display(deltaTable.history())
```

### Scala

```scala
import io.delta.tables._

val deltaTable = DeltaTable.forName(spark, "workspace.default.people_10k")
display(deltaTable.history())
```

### SQL

```sql
DESCRIBE HISTORY workspace.default.people_10k
```

## <a id="time-travel" />Query an earlier version of the table using time travel

Query an older snapshot of a Delta Lake table using Delta Lake time travel. To query a specific version, use the table's version number or timestamp. For example, query version `0` or timestamp `2026-01-05T23:09:47.000+00:00` from the table's history.

### Python

```python
from delta.tables import *

deltaTable = DeltaTable.forName(spark, "workspace.default.people_10k")
deltaHistory = deltaTable.history()

# Query using the version number.
display(deltaHistory.where("version == 0"))

# Query using the timestamp.
display(deltaHistory.where("timestamp == '2026-01-05T23:09:47.000+00:00'"))
```

### Scala

```scala
import io.delta.tables._

val deltaTable = DeltaTable.forName(spark, "workspace.default.people_10k")
val deltaHistory = deltaTable.history()

// Query using the version number.
display(deltaHistory.where("version == 0"))

// Query using the timestamp.
display(deltaHistory.where("timestamp == '2026-01-05T23:09:47.000+00:00'"))
```

### SQL

```sql
-- Query using the version number
SELECT * FROM workspace.default.people_10k VERSION AS OF 0;

-- Query using the timestamp
SELECT * FROM workspace.default.people_10k TIMESTAMP AS OF '2026-01-05T23:09:47.000+00:00';
```

For timestamps, only date or timestamp strings are accepted. For example, strings must be formatted as `"2026-01-05T22:43:15.000+00:00"` or `"2026-01-05 22:43:15"`.

Use `DataFrameReader` options to create a DataFrame from a Delta Lake table that is fixed to a specific version or timestamp of the table.

### Python

```python
# Query using the version number.
df = spark.read.option('versionAsOf', 0).table("workspace.default.people_10k")

# Query using the timestamp.
df = spark.read.option('timestampAsOf', '2026-01-05T23:09:47.000+00:00').table("workspace.default.people_10k")

display(df)
```

### Scala

```scala
// Query using the version number.
val dfVersion = spark.read
  .option("versionAsOf", 0)
  .table("workspace.default.people_10k")

// Query using the timestamp.
val dfTimestamp = spark.read
  .option("timestampAsOf", "2026-01-05T23:09:47.000+00:00")
  .table("workspace.default.people_10k")

display(dfVersion)
display(dfTimestamp)
```

### SQL

```sql
-- Create a temporary view from version 0 of the table.
CREATE OR REPLACE TEMPORARY VIEW people_10k_v0 AS
SELECT * FROM workspace.default.people_10k VERSION AS OF 0;

-- Create a temporary view from a previous timestamp of the table.
CREATE OR REPLACE TEMPORARY VIEW people_10k_t0 AS
SELECT * FROM workspace.default.people_10k TIMESTAMP AS OF '2026-01-05T23:09:47.000+00:00';

SELECT * FROM people_10k_v0;
SELECT * FROM people_10k_t0;
```

For more information, see [Work with table history](https://docs.databricks.com/aws/en/tables/history.md).

## <a id="optimize" />Optimize a table

Multiple changes to a table can create several small files, which slows read query performance. Use the optimize operation to improve speed by combining small files into larger ones. See [OPTIMIZE](https://docs.databricks.com/aws/en/sql/language-manual/delta-optimize.md).

### Python

```python
from delta.tables import *

deltaTable = DeltaTable.forName(spark, "workspace.default.people_10k")
deltaTable.optimize().executeCompaction()
```

### Scala

```scala
import io.delta.tables._

val deltaTable = DeltaTable.forName(spark, "workspace.default.people_10k")
deltaTable.optimize().executeCompaction()
```

### SQL

```sql
OPTIMIZE workspace.default.people_10k
```

> [!NOTE]
>
> If predictive optimization is enabled, you do not need to optimize manually. Predictive optimization automatically manages maintenance tasks. For more information, see [Predictive optimization for Unity Catalog managed tables](https://docs.databricks.com/aws/en/optimizations/predictive-optimization.md).

## <a id="liquid-clustering" />Use liquid clustering

To further improve read performance, use liquid clustering to colocate related data. For example, enable clustering on the high cardinality column `firstName`. Use `OPTIMIZE FULL` to apply clustering to all existing data. For more information, see [Use liquid clustering for tables](https://docs.databricks.com/aws/en/tables/clustering.md).

### Python

```python
spark.sql("ALTER TABLE workspace.default.people_10k CLUSTER BY (firstName)")
spark.sql("OPTIMIZE workspace.default.people_10k FULL")
```

### Scala

```scala
spark.sql("ALTER TABLE workspace.default.people_10k CLUSTER BY (firstName)")
spark.sql("OPTIMIZE workspace.default.people_10k FULL")
```

### SQL

```sql
ALTER TABLE workspace.default.people_10k CLUSTER BY (firstName);
OPTIMIZE workspace.default.people_10k FULL;
```

## <a id="vacuum" />Clean up snapshots with the vacuum operation

Delta Lake has snapshot isolation for reads, which means that it is safe to run an optimize operation while other users or jobs are querying the table. However, you should eventually clean up old snapshots because doing so reduces storage costs, improves query performance, and ensures data compliance. Run the `VACUUM` operation to clean up old snapshots. See [VACUUM](https://docs.databricks.com/aws/en/sql/language-manual/delta-vacuum.md).

### Python

```python
from delta.tables import *

deltaTable = DeltaTable.forName(spark, "workspace.default.people_10k")
deltaTable.vacuum()
```

### Scala

```scala
import io.delta.tables._

val deltaTable = DeltaTable.forName(spark, "workspace.default.people_10k")
deltaTable.vacuum()
```

### SQL

```sql
VACUUM workspace.default.people_10k
```

For more information on using the vacuum operation effectively, see [Remove unused data files with vacuum](https://docs.databricks.com/aws/en/tables/operations/vacuum.md).

## <a id="additional-resources" /> Additional resources

* [Use liquid clustering for tables](https://docs.databricks.com/aws/en/tables/clustering.md)
* [Best practices: Delta Lake](https://docs.databricks.com/aws/en/delta/best-practices.md)
* [What is Delta Lake in Databricks?](https://docs.databricks.com/aws/en/delta/index.md)
