Sub topic 4
The three-level namespace
This chapter assumes you can write basic SQL (CREATE, SELECT, INSERT). It also assumes you have used a Databricks notebook or the SQL editor and know that a metastore is the top-level container for Unity Catalog metadata. Catalogs, schemas, and tables each get their own chapter later, so this one covers only how the three levels fit together and how names resolve.
Three levels, one address
Unity Catalog names every table with three parts separated by dots:
catalog.schema.table- The catalog is the first level. It usually groups data by environment, team, or business domain.
- The schema is the second level. It groups related tables, views, volumes, and functions inside a catalog. Some tools call a schema a database.
- The table is the third level. It holds the rows.
Each metastore holds many catalogs. Each catalog holds many schemas. Each schema holds many tables. The same path also forms the securable object hierarchy that privileges follow. A securable object is anything you can grant access to.
Fully qualified names
A fully qualified name gives all three parts, so it always points at one object, whatever your session settings are. The following statements create the objects and a table at that address:
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)
);Once the table exists, you can write to it and query it by the same name:
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;Short names with USE
Typing three parts every time is tedious. You can set the current catalog and schema for your session, and then use short names:
USE CATALOG dev;
USE SCHEMA sales;
SELECT * FROM orders;Unity Catalog resolves a name by filling in whatever you leave out from the current catalog and schema:
| You write | Resolves to |
|---|---|
| `dev.sales.orders` | `dev.sales.orders` |
| `sales.orders` | `<current catalog>.sales.orders` |
| `orders` | `<current catalog>.<current schema>.orders` |
The resolution depends on session state, so the same query can read different tables in different sessions.
Common errors
- Table or view not found. The name resolved against the wrong current catalog or schema. Run
SELECT current_catalog(), current_schema();to see the defaults, or write the full name. - Schema not found. You gave two parts, so Unity Catalog read the first as a schema in the current catalog, not as a catalog. Add the catalog name.
- Permission denied even though you have SELECT. Access to a table also needs
USE CATALOGon the catalog andUSE SCHEMAon the schema. The privileges chapters cover this. - Special characters in names. A name with a hyphen or a space must be wrapped in backticks, for example `
my-catalog.sales.orders`.
Exercise
Your session has the current catalog dev and the current schema sales. Which table does the query SELECT * FROM staging.orders read, and why might it fail?
Show answer
It reads dev.staging.orders. A two-part name is read as schema.table in the current catalog, so staging is treated as a schema inside dev. It fails with a "schema not found" error if dev has no staging schema. If the table lives in a catalog called staging, you need to write staging.<schema>.orders.
Exercise
Why might a job that uses short names behave differently from the same query run in a notebook?
Show answer
Short names resolve against the current catalog and schema of the session. A job can start with different defaults than your notebook, so the same text can point at a different table or fail. Fully qualified names remove that dependency.