Κοινή χρήση μέσω


Work with managed tables

Azure Databricks manages the lifecycle and file layout for a managed table. Managed tables are the default way to create tables.

Databricks recommends that you use managed tables for all tabular data managed in Azure Databricks.

Note

This article focuses on Unity Catalog managed tables. Managed tables in the legacy Hive metastore have different behaviors. See Database objects in the legacy Hive metastore.

Work with managed tables

You can work with managed tables across all languages and products supported in Azure Databricks. You need certain privileges to create, update, delete, or query managed tables. See Manage privileges in Unity Catalog.

You should not use tools outside of Azure Databricks to manipulate files in managed tables directly.

You should only interact with data files in a managed table using the table name.

Data files for managed tables are stored in the managed storage location associated with the containing schema. See Specify a managed storage location in Unity Catalog.

Create a managed table

By default, any time you create a table using SQL commands, Spark, or other tools in Azure Databricks, the table is managed.

The following SQL syntax demonstrates how to create an empty managed table using SQL. Replace the placeholder values:

  • <catalog-name>: The name of the catalog that will contain the table.
  • <schema-name>: The name of the schema that will contain the table.
  • <table-name>: A name for the table.
  • <column-specification>: The name and data type for each column.
CREATE TABLE <catalog-name>.<schema-name>.<table-name>
(
  <column-specification>
);

Many users create managed tables from query results or DataFrame write operations. The following articles demonstrate some of the many patterns you can use to create a managed table on Azure Databricks:

Required permissions

To create a managed table, you must have:

  • The USE SCHEMA permission on the table’s parent schema.
  • The USE CATALOG permission on the table’s parent catalog.
  • The CREATE TABLE permission on the table’s parent schema.

Drop a managed table

You must be the table’s owner to drop a table. To drop a managed table, run the following SQL command:

DROP TABLE IF EXISTS catalog_name.schema_name.table_name;

When a managed table is dropped, its underlying data is deleted from your cloud tenant within 30 days.