Sub topic 3
Granting and Revoking Privileges
This chapter assumes basic SQL, Databricks notebooks or SQL editor, and familiarity with users, groups, and cloud storage.
Granting and Revoking Privileges
A privilege is permission to perform an action on a securable object. A principal is a user, group, or service principal that receives the permission. Grant access to groups when possible.
GRANT USE CATALOG ON CATALOG dev TO `data-analysts`;
GRANT USE SCHEMA ON SCHEMA dev.sales TO `data-analysts`;
GRANT SELECT ON TABLE dev.sales.orders TO `data-analysts`;
REVOKE SELECT ON TABLE dev.sales.orders FROM `data-analysts`;USE CATALOG and USE SCHEMA let the group reach the table. SELECT lets it read rows. REVOKE removes a privilege that was granted at that object level.
How Privileges Are Inherited
Privileges can apply to child objects. For example, SELECT granted on a schema applies to its tables and views, including tables created later. A catalog-level grant can flow down through its schemas and securable objects.
GRANT SELECT ON SCHEMA dev.sales TO `data-analysts`;
SHOW GRANTS ON SCHEMA dev.sales;Inheritance reduces repeated grants, but it can also grant more access than intended. Check parent objects before troubleshooting a permission.
Storage and Other Securable Objects
Managed tables use storage controlled by Unity Catalog. External tables point to an explicit cloud path. That path must be covered by an external location, and the principal must have the required storage privileges.
Storage credentials define how Unity Catalog authenticates to cloud storage. External locations connect those credentials to approved paths. Keep these objects restricted to administrators and data engineers.
Views expose query results and commonly need SELECT. Volumes store non-tabular files and use privileges such as READ VOLUME or WRITE VOLUME. Functions can require EXECUTE.
Inspecting Objects and Planning Layout
Use metadata commands to verify names, types, and permissions.
SHOW CATALOGS;
SHOW SCHEMAS IN dev;
SHOW TABLES IN dev.sales;
DESCRIBE EXTENDED dev.sales.orders;
SELECT table_schema, table_name, table_type
FROM dev.information_schema.tables
WHERE table_schema = 'sales';A practical layout separates environments or ownership boundaries, such as dev, test, and prod catalogs. Use schemas for teams or data domains, such as sales and finance. Grant broad access at a catalog or schema only when every child object should share that policy.
Exercise
A group has USE CATALOG on dev and USE SCHEMA on dev.sales but cannot query dev.sales.orders. What privilege is missing?
Show answer
SELECT on the table, its schema, or an appropriate parent grant is missing.