Sub topic 5
System tables: where governance data is exposed
This chapter assumes you can write basic SQL, have used a Databricks workspace with a SQL warehouse or notebook, and know the three-level namespace (catalog.schema.table). It also assumes you know how GRANT works in Unity Catalog. Later chapters query lineage and audit data. This one explains where that data lives, who can read it, and how to share it safely.
What system tables are
System tables are read-only tables that Databricks maintains for you. They hold operational data about your account: lineage, audit events, billing usage, compute activity, and more. They live in a catalog named system, inside your Unity Catalog metastore. You query them with ordinary SQL, so you can join them, filter them, build dashboards on them, and put alerts on them.
Four properties matter in practice:
- They are read-only. You cannot insert, update, or delete rows. Databricks writes them.
- They are account-wide. A system table can contain rows from every workspace in your account that uses the same metastore region. A
workspace_idcolumn tells you where each event came from. - They are not real time. Rows arrive with some delay. Do not build a check that expects an event to appear within seconds.
- They have a retention window. Databricks keeps each table for a limited period. The next chapters cover the retention of lineage and audit data. Check the current documentation for exact figures, because they can change.
You can only query system tables from a workspace that is attached to a Unity Catalog metastore. Use a SQL warehouse or a cluster with Unity Catalog access.
Schemas you will meet
Each schema groups related tables. The ones relevant to governance are in access.
| Schema | What it holds | Tables used in this tutorial |
|---|---|---|
| `system.access` | Security and governance events | `audit`, `table_lineage`, `column_lineage` |
| `system.billing` | Usage and pricing data | None |
| `system.compute` | Cluster and warehouse activity | None |
| `system.query` | Query history | None |
The list of schemas grows over time. You can discover what is available in your metastore instead of relying on a static list:
SHOW SCHEMAS IN system;
SHOW TABLES IN system.access;
DESCRIBE TABLE system.access.table_lineage;If SHOW SCHEMAS does not list a schema you expect, the schema is probably not enabled yet. The next section explains why.
Enabling system schemas
Some system schemas are available by default. Others must be enabled before they appear. Enabling is done per schema, by an account admin or a metastore admin, through the system schemas API or the Databricks CLI.
The following example enables the access schema through the REST API. Set DATABRICKS_HOST, DATABRICKS_TOKEN, and METASTORE_ID first.
curl -X PUT \
-H "Authorization: Bearer ${DATABRICKS_TOKEN}" \
"${DATABRICKS_HOST}/api/2.0/unity-catalog/metastores/${METASTORE_ID}/systemschemas/access"You can list the state of every schema with a GET on .../metastores/${METASTORE_ID}/systemschemas. A schema state of ENABLE_COMPLETED means the schema is ready to query.
Who can read system tables
By default, ordinary users cannot read system tables. Account admins and metastore admins can. Everyone else needs explicit privileges, the same way they do for any other table. Reading a system table needs three grants:
USE CATALOGonsystemUSE SCHEMAon the schema, such assystem.accessSELECTon the table
The grants below give a group read access to lineage and audit data. This is the same pattern shown in the tutorial's code examples.
GRANT USE CATALOG ON CATALOG system TO `data-governance`;
GRANT USE SCHEMA ON SCHEMA system.access TO `data-governance`;
GRANT SELECT ON TABLE system.access.table_lineage TO `data-governance`;
GRANT SELECT ON TABLE system.access.column_lineage TO `data-governance`;
GRANT SELECT ON TABLE system.access.audit TO `data-governance`;Grant to groups, not to individual users. This keeps access reviews simple, because you review group membership instead of many separate grants.
Why broad access to `system.access.audit` is risky
Audit rows describe what users did. They contain user email addresses, table names, request parameters, and IP addresses. The table covers every workspace in the account. A grant on system.access.audit therefore lets the reader see the activity of every team, including teams the reader has no other connection to.
Unity Catalog does not filter system table rows per workspace for you. If a workspace owner needs to see only their own events, give them a view that does the filtering. A view lets you narrow both the rows and the columns.
CREATE SCHEMA IF NOT EXISTS governance.shared;
CREATE OR REPLACE VIEW governance.shared.sales_workspace_audit AS
SELECT
event_time,
event_date,
user_identity.email AS user_email,
service_name,
action_name,
response.status_code AS status_code
FROM system.access.audit
WHERE workspace_id = 1234567890123456;
GRANT USE CATALOG ON CATALOG governance TO `sales-leads`;
GRANT USE SCHEMA ON SCHEMA governance.shared TO `sales-leads`;
GRANT SELECT ON VIEW governance.shared.sales_workspace_audit TO `sales-leads`;Replace 1234567890123456 with the real workspace ID. The view's owner needs SELECT on the underlying system table. The sales-leads group needs privileges only on the view and its parent catalog and schema. The view hides request_params, the IP address, and the other workspaces' events.
This view omits some columns, but it does not remove sensitive values from the columns it keeps. If you expose a column such as user_identity.email, you are sharing personal data. Confirm this is acceptable under your organization's policy.
Querying system tables well
System tables can be large, especially audit. A few habits keep queries fast and cheap:
- Filter on
event_datefirst. Audit data is partitioned by date. A condition such asevent_date >= current_date() - INTERVAL 7 DAYSlets the engine skip most files. - Select only the columns you need. Columns such as
request_paramsare maps with many keys. - Keep a small window while you explore. Widen it after the query returns what you expect.
- Persist results you need beyond the retention window. If a regulation requires you to keep audit evidence longer than the system table does, copy it on a schedule into a table you own.
Here is a simple scheduled copy. It appends each day's audit events for one service to your own table. Run it once a day, after the previous day's data has had time to arrive.
CREATE TABLE IF NOT EXISTS governance.archive.uc_audit_events AS
SELECT *
FROM system.access.audit
WHERE 1 = 0;
INSERT INTO governance.archive.uc_audit_events
SELECT *
FROM system.access.audit
WHERE service_name = 'unityCatalog'
AND event_date = current_date() - INTERVAL 1 DAY;The WHERE 1 = 0 clause creates the table with the right columns and no rows. Running the INSERT twice for the same day produces duplicates. In production, use a MERGE on event_id or track which dates you have already loaded.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| `PERMISSION_DENIED` or "does not have USE CATALOG on Catalog 'system'" | The user has not been granted the three required privileges | Grant `USE CATALOG`, `USE SCHEMA`, and `SELECT` to a group the user belongs to |
| Schema `access` is missing from `SHOW SCHEMAS IN system` | The schema is not enabled | An admin enables it through the system schemas API |
| Query returns no rows for recent events | Ingestion delay, or the schema was enabled after the event happened | Wait and retry, and widen the date range |
| Query is slow and scans a lot of data | No `event_date` filter | Add a date filter and select fewer columns |
| Rows from other teams' workspaces appear | System tables are account-wide | Filter on `workspace_id`, or share through a view |
Summary
- System tables are read-only tables in the
systemcatalog. They expose governance and operational data for your whole account. - Lineage and audit data live in
system.access. Some schemas must be enabled before you can see them. - Access needs
USE CATALOG,USE SCHEMA, andSELECT. Grant on named tables to groups, not on whole schemas to individuals. - Share narrow slices through views. Filter on
event_datefor speed and copy data you must keep beyond the retention window.
Exercise
A team lead needs to see audit events for only their own workspace. A colleague proposes running GRANT SELECT ON TABLE system.access.audit to the team lead's group. Explain the problem with that plan and describe a better approach, including which privileges each party needs.
Show answer
The system.access.audit table is account-wide, so the grant would show the group events from every workspace, including user emails and request parameters of other teams. A better approach is to create a view in a catalog you manage that selects only the needed columns and filters on the team's workspace_id. The view owner needs SELECT on system.access.audit (and USE CATALOG and USE SCHEMA on system and system.access). The team lead's group needs only USE CATALOG and USE SCHEMA on the view's catalog and schema, plus SELECT on the view itself.
Exercise
You run SHOW SCHEMAS IN system and the access schema is not listed. What is the most likely cause, and who can fix it?
Show answer
The system schema has not been enabled for the metastore. An account admin or metastore admin can enable it through the system schemas API or the Databricks CLI. Data from before the schema was enabled may not be available.