Sub topic 2
Granting, Revoking, and Inspecting Privileges
Assume you know basic SQL, Databricks notebooks or SQL editor, and the difference between users, groups, and service principals. Unity Catalog uses SQL privileges to control access to catalogs, schemas, tables, volumes, functions, and other securable objects.
Grant, revoke, and inspect access
A principal is a user, service principal, or group that can receive permissions. Grant access to groups rather than individual users whenever possible.
GRANT USE CATALOG ON CATALOG main TO `data-analysts`;
GRANT USE SCHEMA ON SCHEMA main.sales TO `data-analysts`;
GRANT SELECT ON TABLE main.sales.orders TO `data-analysts`;
SHOW GRANTS ON TABLE main.sales.orders;
SHOW GRANTS `data-analysts` ON SCHEMA main.sales;
REVOKE SELECT ON TABLE main.sales.orders FROM `data-analysts`;USE CATALOG and USE SCHEMA allow a principal to resolve objects in the hierarchy. SELECT allows reading table data. SHOW GRANTS helps verify both object-level grants and grants held by a principal.
Privilege inheritance
Privileges granted on a catalog or schema can flow down to supported child objects. For example, SELECT on a schema can apply to its tables and views. This reduces repetitive grants, but it also increases the impact of a broad grant.
GRANT SELECT ON SCHEMA main.sales TO `data-analysts`;
REVOKE SELECT ON SCHEMA main.sales FROM `data-analysts`;Ownership and delegated management
Every securable object has an owner. The owner can manage the object and its permissions. Transfer ownership to a group so administration does not depend on one employee.
ALTER TABLE main.sales.orders OWNER TO `data-engineers`;The MANAGE privilege can delegate administrative actions without transferring ownership. Use it carefully because it can allow a principal to change grants or ownership.
Administrative roles
Account administrators manage account-wide settings and can assign metastore administration. A metastore administrator manages Unity Catalog objects across the metastore. Workspace administrators manage workspace settings and users, but workspace administration alone does not automatically grant access to table data.
Exercise
What access does a group need to query main.sales.orders?
Show answer
It needs USE CATALOG on main, USE SCHEMA on main.sales, and SELECT on the table or an inherited SELECT grant.