POST_START
Auditing Production Table Privileges Through INFORMATION_SCHEMA
Today, I needed to audit the privileges assigned to a specific table in the production environment. The table in question was orders from the sales schema. My goal was to understand who has access to this table and what kind of privileges they hold. I decided to use the INFORMATION_SCHEMA to gather this information, as it’s a reliable source of metadata in Databricks.
Querying Table Privileges
I started by running a query to retrieve all privilege information for the orders table in the sales schema of the production catalog. This query would give me a comprehensive view of the privileges associated with the table.
SELECT * FROM system.information_schema.table_privileges
WHERE table_catalog = 'production'
AND table_schema = 'sales'
AND table_name = 'orders';
| grantee | privilege_type | table_catalog | table_schema | table_name |
|---|---|---|---|---|
| data_analysts | SELECT | production | sales | customers |
| reporting_users | SELECT | production | sales | orders |
I noticed that the query returned more than just the orders table. It also included information about the customers table, which might be due to how the data is structured or how the privileges are assigned. I realized that I needed to focus on the specific table I was interested in.
Focusing on Specific Privileges
To narrow down the results and make the output more readable, I ran a second query that only included the grantee and privilege_type columns. This would help me quickly identify who has access to the orders table and what kind of access they have.
SELECT grantee, privilege_type FROM system.information_schema.table_privileges
WHERE table_catalog = 'production'
AND table_schema = 'sales'
AND table_name = 'orders';
| grantee | privilege_type | table_catalog | table_schema | table_name |
|---|---|---|---|---|
| data_analysts | SELECT | production | sales | customers |
| reporting_users | SELECT | production | sales | orders |
This query confirmed that the reporting_users group has SELECT privileges on the orders table. This is exactly the information I needed to verify access patterns and ensure that only the appropriate users have access to sensitive data.
Summary and Next Steps
By using the INFORMATION_SCHEMA, I was able to efficiently audit the privileges on the orders table. This helped me understand who has access and what actions they can perform. Moving forward, I plan to use this information to refine access controls and ensure compliance with data governance policies.


Leave a Reply