Sub topic 12
Storage credentials, external locations, and managed storage
This chapter assumes you know basic SQL, the three-level namespace (catalog.schema.table), and the difference between managed and external tables. It explains how Unity Catalog controls access to the cloud storage that sits under your tables.
Why storage needs its own objects
Unity Catalog grants privileges on tables, but the data lives as files in cloud object storage. If any user could read those files directly, the table privileges would mean nothing. Unity Catalog therefore adds two objects that govern storage access:
- A storage credential holds the cloud identity (for example, an AWS IAM role) that Unity Catalog uses to reach storage. Users never see the secret.
- An external location pairs a storage path with a storage credential. Privileges on the external location decide who may use that path.
Both are securable objects in the metastore. Administrators create them. Ordinary users receive privileges on them.
External tables and external locations
An external table points at files you manage at a path of your choosing. Creating one with LOCATION works only when the path falls under an external location, and only when you hold the right privilege on that location.
CREATE TABLE dev.sales.raw_orders (
order_id BIGINT,
payload STRING
)
LOCATION 's3://example-bucket/raw/orders';The bucket name is a placeholder. If no external location covers the path, or you lack CREATE EXTERNAL TABLE on it, the statement fails.
Dropping an external table removes the metadata only. The files stay in storage.
Managed storage
Managed tables need no LOCATION. Unity Catalog stores their files in a managed storage location and controls the file layout itself. It picks that location by looking from the most specific object outward:
- The schema's managed location, if one is set.
- The catalog's managed location, if one is set.
- The metastore's root storage, if one was configured.
The first location found is used. This lets you place the data of one catalog, such as a regulated business unit, in its own bucket without changing table definitions.
Dropping a managed table deletes its metadata and, after a retention period, its data files. Pick managed tables when you want Unity Catalog to own the lifecycle. Pick external tables when other tools must read or write the same files, or when the data must stay at a fixed path.
| Aspect | Managed table | External table |
|---|---|---|
| Where files live | Managed storage chosen by Unity Catalog | Path you give in `LOCATION` |
| Needs external location | No | Yes |
| Effect of `DROP TABLE` | Data is deleted after a retention period | Files remain |
Common errors
- A "no external location covers this path" style failure means the path is not under any registered external location. Ask an administrator to create one.
- A permission failure on an external path usually means you lack a privilege on the external location, even if you can create tables in the schema.
- Overlapping external locations are not allowed. Do not register a path inside another location's path.
- Reading the files directly with a cloud tool does not go through Unity Catalog. Restrict direct bucket access so that Unity Catalog remains the only route.
Exercise
A catalog has a managed location set, and its schema sales has none. Where does the files of a new managed table dev.sales.orders go? What changes if the schema later gets its own managed location, and what happens to existing tables?
Show answer
The files go to the catalog's managed location, because the schema has none. If the schema gets its own managed location, new managed tables in that schema use it. Existing tables stay where they were created, since their storage path is already fixed.
Exercise
Why does CREATE TABLE ... LOCATION 's3://example-bucket/raw/orders' fail for a user who has CREATE TABLE on the schema?
Show answer
The path must be covered by an external location, and the user needs the privilege to create external tables on that location. Schema privileges alone are not enough.