Sub topic 7
Tables
Tables are the objects that hold your data in Unity Catalog. This chapter covers how a table is named and created, what is stored for it, and what to watch for when you work with one. It assumes you know basic SQL and have read the chapters on the metastore, catalogs, and schemas.
Where a table sits in the hierarchy
A table is the third level of the namespace. It lives in a schema, which lives in a catalog, which lives in a metastore. Its full name has three parts separated by dots: catalog.schema.table.
The table name only has to be unique inside its schema. Two schemas can each hold a table called orders without conflict, because dev.sales.orders and dev.marketing.orders are different full names.
What a table is
A table is a set of rows with a fixed set of named, typed columns. The data itself is stored as files in cloud object storage. Unity Catalog does not hold the rows. It holds the metadata: the table's name, its columns and types, its owner, its storage location, and the privileges granted on it.
This split has two practical effects:
- Dropping or altering a table changes metadata first. Whether the files are also affected depends on whether the table is managed or external, which the next chapter covers.
- Access is checked against Unity Catalog, so a user needs privileges on the table even if they could technically read the underlying files.
Tables in Databricks are Delta tables by default. Delta stores data as Parquet files plus a transaction log, which gives you ACID transactions (changes either fully apply or do not apply at all) and a history of versions.
Creating a table
You need a catalog and schema first. The following statements create both, then a table inside them.
CREATE CATALOG IF NOT EXISTS dev;
CREATE SCHEMA IF NOT EXISTS dev.sales;
CREATE TABLE IF NOT EXISTS dev.sales.orders (
order_id BIGINT,
customer_id BIGINT,
order_ts TIMESTAMP,
amount DECIMAL(10,2)
);The table is addressed as dev.sales.orders. Because no LOCATION is given, Unity Catalog decides where the files go, using the managed storage configured for the schema, catalog, or metastore. That makes it a managed table.
To create a table you need these privileges:
USE CATALOGon the parent catalog.USE SCHEMAon the parent schema.CREATE TABLEon the parent schema.
The creator becomes the table's owner.
Writing and querying
Once the table exists, you insert and query it with ordinary SQL.
INSERT INTO dev.sales.orders VALUES
(1, 100, TIMESTAMP'2026-01-15 09:30:00', 25.50),
(2, 101, TIMESTAMP'2026-01-15 10:05:00', 80.00);
SELECT customer_id, SUM(amount) AS total_amount
FROM dev.sales.orders
GROUP BY customer_id;The fully qualified name works from any session, in any catalog or schema context. This is the form to prefer in shared code, because it does not depend on session state.
Short names and the current catalog and schema
Typing three parts every time is tedious in interactive work. You can set a default catalog and schema, and then refer to the table by its short name.
USE CATALOG dev;
USE SCHEMA sales;
SELECT * FROM orders;Here is how Unity Catalog resolves a name, depending on how many parts you give it:
| What you write | How it is resolved |
|---|---|
| `dev.sales.orders` | Used exactly as written. |
| `sales.orders` | The schema `sales` is looked up in the current catalog. |
| `orders` | The table is looked up in the current catalog and current schema. |
If you have not set a current catalog or schema, Databricks falls back to the workspace default, which depends on how the workspace is configured. If a short name resolves to a different table than you expected, check the current context with SELECT current_catalog(), current_schema();.
Table types you will see
Not every object listed under a schema is a plain table. The table_type shown for an object tells you what it is.
| Type | Meaning |
|---|---|
| `MANAGED` | Unity Catalog manages both the metadata and the data files. |
| `EXTERNAL` | Unity Catalog manages the metadata. The files live at a path you provide. |
| `VIEW` | A saved query. It stores no data of its own. |
Views, volumes, and functions are covered in a later chapter. For now, note that a view shares the table namespace, so a view and a table cannot have the same name in the same schema.
Creating a table at a path
Adding a LOCATION clause creates an external table.
CREATE TABLE dev.sales.raw_orders (
order_id BIGINT,
payload STRING
)
LOCATION 's3://example-bucket/raw/orders';This works only if the path is covered by an external location, and you hold the privileges to use it. The bucket name above is a placeholder. Without that coverage the statement fails with a permission error. The distinction between managed and external tables, and the storage objects behind it, gets its own chapters.
Looking at a table
Two quick checks show you what a table is and how it is defined.
SHOW TABLES IN dev.sales;
DESCRIBE EXTENDED dev.sales.orders;SHOW TABLES lists the tables in a schema. DESCRIBE EXTENDED prints the columns, and below them a detailed block with the owner, the table type, the storage location, and the provider (usually delta). When a table behaves unexpectedly, this is the first command to run.
You can also query the catalog's information_schema, which is a set of read-only views over the metadata.
SELECT table_schema, table_name, table_type
FROM dev.information_schema.tables
WHERE table_schema = 'sales';The information_schema approach is useful when you want to filter or join metadata with ordinary SQL. A later chapter covers it in detail.
Common errors
These are the problems intermediate users hit most often with tables.
TABLE_OR_VIEW_NOT_FOUND. The name resolved to something that does not exist. Usually the current catalog or schema is not what you thought, or you lackUSE CATALOGorUSE SCHEMAand the object is hidden from you. Check your context and your privileges.- Permission denied on a table you can see. Having
SELECTon the table is not enough. You also needUSE CATALOGon the catalog andUSE SCHEMAon the schema. - Create fails with a location error. The
LOCATIONpath is not covered by an external location, or you lack the privilege to use that location. - A table is created in an unexpected place. You ran
CREATE TABLE orderswith no qualifier, and it landed in the current catalog and schema. RunSELECT current_catalog(), current_schema();before creating tables interactively. - Two tables look identical. They have the same table name in different schemas. Compare the full three-part names.
Dropping tables
DROP TABLE removes the table from the catalog. What happens to the data depends on the table type:
- For a managed table, the data is scheduled for deletion, and Databricks keeps it for a retention window before it is removed permanently. Within that window you may be able to restore the table with
UNDROP TABLE. - For an external table, only the metadata is removed. The files at the path are left alone.
Only the owner of a table, or a user with the right ownership-level privileges on the parent objects, can drop it.
Summary of the working model
- A table is named
catalog.schema.table, and its name is unique within its schema. - Unity Catalog stores the table's metadata and permissions. The rows live as files in cloud storage.
- Creating a table needs
USE CATALOG,USE SCHEMA, andCREATE TABLE. - Short names depend on the current catalog and schema, so use full names in shared code.
LOCATIONmakes a table external and needs an external location.DESCRIBE EXTENDEDtells you the owner, type, and location.
Exercise
A teammate runs SELECT * FROM orders; in a notebook and gets the rows from dev.sales.orders. Your scheduled job runs the same statement and reads a different table. What is the most likely cause, and how do you fix it?
Show answer
The short name orders resolves against the current catalog and schema, and the job runs with a different default than the notebook. Fix it by using the fully qualified name dev.sales.orders in the job, or by issuing USE CATALOG dev; USE SCHEMA sales; before the query. Use the fully qualified name in production code.
Exercise
A user has SELECT on dev.sales.orders but the query fails with a permission error. Which two other privileges should you check, and on which objects?
Show answer
Check USE CATALOG on the catalog dev and USE SCHEMA on the schema dev.sales. SELECT on the table alone does not give access without them.
Exercise
You run CREATE TABLE dev.sales.raw_orders (...) LOCATION 's3://example-bucket/raw/orders'; and it fails. Name two likely reasons and the command you would use to confirm that a table you created earlier is managed.
Show answer
The path may not be covered by an external location, or you may lack the privilege to use the external location that covers it. To confirm that an existing table is managed, run DESCRIBE EXTENDED on it and read the type field.