What is RBAC in Snowflake?
At Maple Market, Ana reads sales reports. Ravi investigates raw orders. Quinn checks test results. A scheduled job writes new orders. Each needs access to different parts of Snowflake. If Mira, the administrator, assigned every permission to every person one at a time, each new hire and team move would be harder to review.
Role-based access control (RBAC) gives a job a reusable set of permissions. Mira grants the reporting permissions to an analyst role, then gives Ana that role. A new analyst can use the same role. When Ana changes teams, Mira can remove that membership without changing how the report works for everyone else.
A user is the identity Snowflake recognizes for a person or a program. A role collects permissions. A privilege allows a specific action such as reading a table with SELECT. A securable object is something Snowflake controls access to, such as a table, schema, database or virtual warehouse. A warehouse provides the computing power for the queries in this lab.
- Ana · userreceives to Analyst · job role
- Analyst · job roleinherits to Report reader · access role
- Report reader · access roleholds to SELECT · privilege
- SELECT · privilegepermits rows to be read from to REPORTING.ORDERS · object
Signing in and reading a table are separate checks
Authentication proves who is connecting. Ana can use company single sign-on (SSO). A workload can use an approved method such as key-pair authentication, where it proves it holds a private key. Authorization decides whether the connected session can do an action. Ana can sign in successfully and still be denied access to RAW.ORDERS_INBOX.
If the job cannot connect at all, inspect the connection, sign-in evidence and account policy. If it connects and a query fails, capture the statement, session role, warehouse and exact object name. Start with the check that produced the failure.
RBAC is one part of Snowflake access control. Discretionary access control (DAC) gives each object an owner, who can usually grant access in a regular schema. Managed access schemas centralize grant decisions with the schema owner or a role with MANAGE GRANTS. User-based access control (UBAC) allows some privileges to be granted directly to users. Snowflake considers direct user privileges with USE SECONDARY ROLES ALL. Maple Market uses job roles so access is easier to reuse and review.
Choose the system role for the work
Snowflake supplies built-in account roles for different administrative duties. In a role hierarchy the parent receives the privileges of its child. SECURITYADMIN inherits USERADMIN. ACCOUNTADMIN inherits both SECURITYADMIN and SYSADMIN. SECURITYADMIN and SYSADMIN are separate branches.
PUBLIC is automatically available to every user and role. A table grant to PUBLIC can make a private design ineffective, so check it before treating a test as isolated. Use an approved administrative role for each administrative step and a custom role for everyday work.
Organization administration is a separate scope. GLOBALORGADMIN works in the organization account. Snowflake is phasing out the use of ORGADMIN in regular accounts for multi-account organizations. Neither organization role is required for this exercise.
| Role | Job |
|---|---|
| USERADMIN | Creates users and account roles. Manages the users and roles it owns. |
| SECURITYADMIN | Manages grants across the account. Inherits USERADMIN privileges. |
| SYSADMIN | Creates warehouses and databases and manages objects it owns or inherits. |
| ACCOUNTADMIN | Has account-level authority and inherits SYSADMIN and SECURITYADMIN. Reserve it for work that needs it. |
| PUBLIC | Provides shared baseline access. Keep business data grants out of it unless everyone should have them. |
- USERADMINpasses privileges to to SECURITYADMIN
- SECURITYADMINpasses privileges to to ACCOUNTADMIN
- SYSADMINpasses privileges to to ACCOUNTADMIN
Build custom roles around job duties
A functional role describes a job, such as analyst or engineer. An access role describes a resource and an action, such as read reports or insert raw orders. These are design names. Both can be built from Snowflake roles. Adding someone to Analytics changes their job membership. Adding a report table changes the report access bundle.
In GRANT ROLE DLC_RBAC_INGEST TO ROLE DLC_RBAC_ENGINEER, INGEST is the child. ENGINEER inherits its INSERT privilege. The scheduled job receives INGEST directly and has no path to ENGINEER’s raw SELECT privilege. Grant the top of each lab branch to SYSADMIN so it can inherit the branch. Keep day-to-day roles separate.
An account role works across the account. It can be activated in a session and can have privileges on the warehouse. A database role collects permissions inside one database and cannot be selected with USE ROLE or used as a secondary role. In this lab, grant the database role to the ANALYST account role. The account role connects that database access to an analyst’s session and adds warehouse access.
- REPORT_READER · database rolepasses report access to to DLC_RBAC_ANALYST
- DLC_RBAC_INGESTpasses raw insert to to DLC_RBAC_ENGINEER
- DLC_RBAC_ANALYSTpasses analyst access to to SYSADMIN
- DLC_RBAC_ENGINEERpasses engineering access to to SYSADMIN
- DLC_RBAC_QApasses QA access to to SYSADMIN
Work out which permissions Snowflake can use
The primary role is the main active account role in a session. A user’s default role can start the session in the right role after login. The client can request another assigned role. A default is a starting choice. A role grant is what makes the role available. USE ROLE changes the primary role in the current session.
Secondary roles let a session use additional assigned account roles. For a normal SELECT, Snowflake can combine the privileges of active roles and the roles they inherit. Creating an object uses the primary role and its inherited privileges for authorization. The primary role normally owns the new object. Configured future OWNERSHIP can assign it elsewhere.
For a clean permission test, switch to the role under test and run USE SECONDARY ROLES NONE. The role still has its inherited privileges and PUBLIC access. If Ana can read raw orders with secondary roles enabled, check whether a second role or a direct user grant supplies access. A clean denial requires those extra paths to be absent or out of scope for the test.
In this lab Ana needs USAGE on DLC_RBAC_WH to run the query, USAGE on DLC_RBAC_DB and REPORTING to reach the table, and SELECT on ORDERS to read its rows. These are the minimal privileges used here. Snowflake can also recognize other qualifying rights, for example ownership. If schema USAGE is missing, table SELECT alone cannot complete this path.
- SELECT on REPORTING.ORDERSuses permissions from to Active roles and inherited grants
- Active roles and inherited grantsneed USAGE on to DLC_RBAC_WH
- Active roles and inherited grantsneed USAGE on to DLC_RBAC_DB
- DLC_RBAC_DBcontains the schema that needs USAGE to REPORTING schema
- REPORTING schemacontains the table that needs SELECT to ORDERS table
Test active roles and least privilege →
Check the session before checking grants
For a failed SELECT, record the identity and session roles so the grant reviewer can reproduce the same context. For a failed CREATE, focus on the primary role and its inherited rights.
- Statement and active sessionfor a CREATE, check to CREATE · primary role branch
- Statement and active sessionfor a SELECT, check to SELECT · active role branches
- CREATE · primary role branchuse the relevant branch to to Check required grants and PUBLIC
- SELECT · active role branchescollect inherited rights and to Check required grants and PUBLIC
- Check required grants and PUBLICauthorize or deny the statement to Expected rows or denial
Hands-on lab · Plan and create the roles
Use an approved disposable Snowflake account and a lab operator already authorized to switch to SYSADMIN, USERADMIN and SECURITYADMIN. Open a fresh worksheet for the lab. Standard account roles, database roles and regular schemas are enough. The small virtual warehouse can incur credits. Read the expected outcomes without connecting if you do not have this environment.
Replace the unquoted name DLC_RBAC_TESTER in steps 6, 12 and 13 with the actual Snowflake user name returned in step 1. This is the existing lab operator. Temporary role grants let that operator test each role with secondary roles off. The four fictional users have no credentials and are disabled. When testing an actual login, use separately approved identities and authentication rather than enabling the placeholders.
Run in order and execute expected failures individually. Choose a fresh prefix if your practice account already uses these names and replace it consistently across the steps. Stop before cleanup if you cannot prove the objects and users came from this exercise.
1. Decide who needs what
Mira uses SECURITYADMIN to check for names already in use. Record the signed-in test operator and compare the four job roles against the intended actions. SHOW commands check visible metadata and do not read business data. If a matching lab resource exists, identify its owner and choose fresh names before creating anything.
Expect no DLC_RBAC resources matching the names below. No SQL grant should be issued until the allowed and denied operations are clear.
| Identity | Role or authority | Allowed by design | Keep outside the role |
|---|---|---|---|
| Ana · analyst | DLC_RBAC_ANALYST | Read the sales orders in REPORTING | Write reports or read RAW |
| Ravi · data engineer | DLC_RBAC_ENGINEER | Read and insert raw orders | Read reports by default |
| Quinn · quality assurance (QA) | DLC_RBAC_QA | Read QA checks after the repair | Change QA results or read raw orders |
| Scheduled extract, transform and load (ETL) job | DLC_RBAC_INGEST | Insert into the raw inbox | Read the inbox or write reports |
| Mira · lab administrator | SYSADMIN / USERADMIN / SECURITYADMIN | Create objects and manage lab access in the appropriate role | Use account admin for routine queries |
USE SECONDARY ROLES NONE;
USE ROLE SYSADMIN;
USE ROLE USERADMIN;
USE ROLE SECURITYADMIN;
SELECT CURRENT_USER() AS LAB_OPERATOR, CURRENT_ROLE() AS PRIMARY_ROLE;
SHOW DATABASES LIKE 'DLC_RBAC_DB';
SHOW WAREHOUSES LIKE 'DLC_RBAC_WH';
SHOW ROLES LIKE 'DLC_RBAC_%';
SHOW USERS LIKE 'DLC_RBAC_%';2. Create the warehouse, database and sample rows
SYSADMIN owns the data objects in this lab. A database is the top-level container for these data objects. A schema groups related tables within it. Keep raw inputs, business reports and QA checks in three separate schemas so each privilege has a clear boundary.
WAREHOUSE_SIZE sets the compute size. INITIALLY_SUSPENDED waits for work and AUTO_SUSPEND stops idle compute after 60 seconds. The warehouse resumes for these statements when needed. AUTOCOMMIT makes the small inserts durable after each successful statement in this worksheet.
Expect 2 report rows totaling 100, one raw inbox row for order 101, and one PASS check for the report total. A duplicate-name error means setup has already run or the name is taken. Verify the existing object and rows before retrying.
USE ROLE SYSADMIN;
CREATE WAREHOUSE DLC_RBAC_WH
WITH WAREHOUSE_SIZE = 'XSMALL'
AUTO_SUSPEND = 60 AUTO_RESUME = TRUE INITIALLY_SUSPENDED = TRUE;
USE WAREHOUSE DLC_RBAC_WH;
ALTER SESSION SET AUTOCOMMIT = TRUE;
CREATE DATABASE DLC_RBAC_DB;
CREATE SCHEMA DLC_RBAC_DB.RAW;
CREATE SCHEMA DLC_RBAC_DB.REPORTING;
CREATE SCHEMA DLC_RBAC_DB.QA;
CREATE TABLE DLC_RBAC_DB.RAW.ORDERS_INBOX (ORDER_ID NUMBER, AMOUNT NUMBER);
CREATE TABLE DLC_RBAC_DB.REPORTING.ORDERS (ORDER_ID NUMBER, AMOUNT NUMBER);
CREATE TABLE DLC_RBAC_DB.QA.LOAD_CHECKS (CHECK_NAME VARCHAR, RESULT VARCHAR);
INSERT INTO DLC_RBAC_DB.RAW.ORDERS_INBOX VALUES (101, 40);
INSERT INTO DLC_RBAC_DB.REPORTING.ORDERS VALUES (101, 40), (102, 60);
INSERT INTO DLC_RBAC_DB.QA.LOAD_CHECKS VALUES ('Sales total', 'PASS');
SELECT COUNT(*) AS ROWS_LOADED, SUM(AMOUNT) AS SALES
FROM DLC_RBAC_DB.REPORTING.ORDERS;
SELECT ORDER_ID, AMOUNT FROM DLC_RBAC_DB.RAW.ORDERS_INBOX;
SELECT CHECK_NAME, RESULT FROM DLC_RBAC_DB.QA.LOAD_CHECKS;3. Create the custom roles
USERADMIN creates the four account roles for jobs and raw insert access. SYSADMIN owns DLC_RBAC_DB and creates REPORT_READER inside it. A database role has a database-qualified name. Creating a role sets up the bundle. Step 5 fills it with specific permissions.
Expect four custom account roles and REPORT_READER in DLC_RBAC_DB. Snowflake can show the creator’s ownership or built-in access in metadata. The new roles have no lab data grants yet.
USE ROLE USERADMIN;
CREATE ROLE DLC_RBAC_ANALYST;
CREATE ROLE DLC_RBAC_ENGINEER;
CREATE ROLE DLC_RBAC_QA;
CREATE ROLE DLC_RBAC_INGEST;
SHOW ROLES LIKE 'DLC_RBAC_%';
USE ROLE SYSADMIN;
CREATE DATABASE ROLE DLC_RBAC_DB.REPORT_READER;
SHOW DATABASE ROLES IN DATABASE DLC_RBAC_DB;4. Connect the roles in the right direction
SECURITYADMIN can manage grants on the account roles and inherits USERADMIN’s ownership. SYSADMIN owns the database role and grants it to the analyst account role. The name after TO ROLE is the parent. The engineer needs the ingest permission and its own read permission. The job needs only ingest.
SHOW GRANTS OF ROLE DLC_RBAC_INGEST should show DLC_RBAC_ENGINEER as a role recipient. SHOW GRANTS TO ROLE DLC_RBAC_ANALYST should show DLC_RBAC_DB.REPORT_READER as a database role grant. Check that no analyst-to-engineer or engineer-to-ingest grant was created.
USE ROLE SECURITYADMIN;
GRANT ROLE DLC_RBAC_INGEST TO ROLE DLC_RBAC_ENGINEER;
GRANT ROLE DLC_RBAC_ENGINEER TO ROLE SYSADMIN;
GRANT ROLE DLC_RBAC_ANALYST TO ROLE SYSADMIN;
GRANT ROLE DLC_RBAC_QA TO ROLE SYSADMIN;
SHOW GRANTS OF ROLE DLC_RBAC_INGEST;
USE ROLE SYSADMIN;
GRANT DATABASE ROLE DLC_RBAC_DB.REPORT_READER TO ROLE DLC_RBAC_ANALYST;
USE ROLE SECURITYADMIN;
SHOW GRANTS TO ROLE DLC_RBAC_ANALYST;Hands-on lab · Grant, test and repair access
Use the matrix to predict each result before you run the statement. Record the current user, current role and expected result together.
5. Grant only the required privileges
SECURITYADMIN applies the grants. Give warehouse USAGE to account roles. Give the reporting database role schema USAGE and table SELECT. Snowflake gives a database role USAGE on its parent database when the role is created.
Give the raw writer only INSERT on the inbox. Ravi inherits it and also gets raw SELECT. Quinn gets SELECT on LOAD_CHECKS and database USAGE. Leave out QA schema USAGE on purpose so you can diagnose an incomplete grant path.
Verify REPORT_READER has SELECT and REPORTING USAGE. For QA, the direct grants should show warehouse USAGE, database USAGE and table SELECT, with no QA schema USAGE. A fresh lab must have no business grants to PUBLIC.
USE ROLE SECURITYADMIN;
GRANT USAGE ON WAREHOUSE DLC_RBAC_WH TO ROLE DLC_RBAC_ANALYST;
GRANT USAGE ON WAREHOUSE DLC_RBAC_WH TO ROLE DLC_RBAC_INGEST;
GRANT USAGE ON WAREHOUSE DLC_RBAC_WH TO ROLE DLC_RBAC_QA;
GRANT USAGE ON SCHEMA DLC_RBAC_DB.REPORTING
TO DATABASE ROLE DLC_RBAC_DB.REPORT_READER;
GRANT SELECT ON TABLE DLC_RBAC_DB.REPORTING.ORDERS
TO DATABASE ROLE DLC_RBAC_DB.REPORT_READER;
GRANT USAGE ON DATABASE DLC_RBAC_DB TO ROLE DLC_RBAC_INGEST;
GRANT USAGE ON SCHEMA DLC_RBAC_DB.RAW TO ROLE DLC_RBAC_INGEST;
GRANT INSERT ON TABLE DLC_RBAC_DB.RAW.ORDERS_INBOX TO ROLE DLC_RBAC_INGEST;
GRANT SELECT ON TABLE DLC_RBAC_DB.RAW.ORDERS_INBOX TO ROLE DLC_RBAC_ENGINEER;
GRANT USAGE ON DATABASE DLC_RBAC_DB TO ROLE DLC_RBAC_QA;
GRANT SELECT ON TABLE DLC_RBAC_DB.QA.LOAD_CHECKS TO ROLE DLC_RBAC_QA;
SHOW GRANTS TO DATABASE ROLE DLC_RBAC_DB.REPORT_READER;
SHOW GRANTS TO ROLE DLC_RBAC_QA;
SHOW GRANTS TO ROLE PUBLIC INCLUDE HIERARCHY;
SHOW FUTURE GRANTS TO ROLE PUBLIC INCLUDE HIERARCHY;6. Assign roles to users
USERADMIN creates three disabled person users and one disabled service user. A service user represents an application rather than a person and uses an approved non-password sign-in method when enabled. SECURITYADMIN assigns each user only the role from the access matrix.
The four temporary grants to the lab operator let you change primary role in the worksheet. Substitute the LAB_OPERATOR name from step 1, quoting it if Snowflake requires quotes. SHOW GRANTS TO USER shows the service identity’s ingest membership. The service user stays disabled throughout this exercise.
USE ROLE USERADMIN;
CREATE USER DLC_RBAC_ANA TYPE = PERSON DISABLED = TRUE;
CREATE USER DLC_RBAC_RAVI TYPE = PERSON DISABLED = TRUE;
CREATE USER DLC_RBAC_QUINN TYPE = PERSON DISABLED = TRUE;
CREATE USER DLC_RBAC_ETL_SVC TYPE = SERVICE DISABLED = TRUE;
USE ROLE SECURITYADMIN;
GRANT ROLE DLC_RBAC_ANALYST TO USER DLC_RBAC_ANA;
GRANT ROLE DLC_RBAC_ENGINEER TO USER DLC_RBAC_RAVI;
GRANT ROLE DLC_RBAC_QA TO USER DLC_RBAC_QUINN;
GRANT ROLE DLC_RBAC_INGEST TO USER DLC_RBAC_ETL_SVC;
-- Replace DLC_RBAC_TESTER with the existing lab operator.
GRANT ROLE DLC_RBAC_ANALYST TO USER DLC_RBAC_TESTER;
GRANT ROLE DLC_RBAC_ENGINEER TO USER DLC_RBAC_TESTER;
GRANT ROLE DLC_RBAC_QA TO USER DLC_RBAC_TESTER;
GRANT ROLE DLC_RBAC_INGEST TO USER DLC_RBAC_TESTER;
SHOW GRANTS TO USER DLC_RBAC_ETL_SVC;
SHOW GRANTS TO USER DLC_RBAC_TESTER;7. Set the default role for the next login
USERADMIN owns the four new users. Set DEFAULT_ROLE to the role you granted each user. The empty secondary-role list makes the initial session easier to reason about when that identity is later configured for login in an approved environment.
DESCRIBE USER should show DLC_RBAC_ANALYST for Ana and DLC_RBAC_INGEST for the job, with both identities still disabled. ALTER USER can accept a default role name without proving the grant exists. Compare the settings with the memberships from step 6.
USE ROLE USERADMIN;
ALTER USER DLC_RBAC_ANA SET DEFAULT_ROLE = DLC_RBAC_ANALYST DEFAULT_SECONDARY_ROLES = ();
ALTER USER DLC_RBAC_RAVI SET DEFAULT_ROLE = DLC_RBAC_ENGINEER DEFAULT_SECONDARY_ROLES = ();
ALTER USER DLC_RBAC_QUINN SET DEFAULT_ROLE = DLC_RBAC_QA DEFAULT_SECONDARY_ROLES = ();
ALTER USER DLC_RBAC_ETL_SVC SET DEFAULT_ROLE = DLC_RBAC_INGEST DEFAULT_SECONDARY_ROLES = ();
DESCRIBE USER DLC_RBAC_ANA;
DESCRIBE USER DLC_RBAC_ETL_SVC;8. Prove that approved actions work
Use the operator’s worksheet. Switch to each custom role and disable secondary roles. CURRENT_ROLE reports the primary role. CURRENT_SECONDARY_ROLES shows the session’s secondary-role setting and roles. USE WAREHOUSE checks compute access independently from the table.
Ana’s role reads orders 101 and 102. The ingest role inserts order 103 once. Ravi’s role sees both raw orders. The child role supplies RAW access and the engineer role supplies SELECT. If you rerun this block, skip the successful insert or use a fresh fixture to avoid duplicates.
| Active role | Statement | Result |
|---|---|---|
| DLC_RBAC_ANALYST | Read reporting orders | 101 / 40 and 102 / 60 |
| DLC_RBAC_INGEST | Append raw order 103 | 1 row inserted |
| DLC_RBAC_ENGINEER | Read raw inbox | 101 / 40 and 103 / 25 |
USE ROLE DLC_RBAC_ANALYST;
USE SECONDARY ROLES NONE;
USE WAREHOUSE DLC_RBAC_WH;
SELECT CURRENT_USER(), CURRENT_ROLE(), CURRENT_SECONDARY_ROLES();
SELECT ORDER_ID, AMOUNT FROM DLC_RBAC_DB.REPORTING.ORDERS ORDER BY ORDER_ID;
USE ROLE DLC_RBAC_INGEST;
USE SECONDARY ROLES NONE;
USE WAREHOUSE DLC_RBAC_WH;
INSERT INTO DLC_RBAC_DB.RAW.ORDERS_INBOX VALUES (103, 25);
USE ROLE DLC_RBAC_ENGINEER;
USE SECONDARY ROLES NONE;
USE WAREHOUSE DLC_RBAC_WH;
SELECT ORDER_ID, AMOUNT FROM DLC_RBAC_DB.RAW.ORDERS_INBOX ORDER BY ORDER_ID;9. Check that other actions are denied
In the operator worksheet, run each role setup and its failing statement separately. The analyst has no raw schema access and no reporting INSERT. The ingest role has no raw SELECT. The QA role currently lacks QA schema USAGE even though it has SELECT on LOAD_CHECKS.
Expect an authorization error or a message that the object does not exist or is not authorized. Compare the SQL name with the known object before concluding access caused the failure. The analyst INSERT has a false filter so an unexpected permission cannot insert a row. Investigate any unexpected success before moving on.
USE ROLE DLC_RBAC_ANALYST;
USE SECONDARY ROLES NONE;
USE WAREHOUSE DLC_RBAC_WH;
-- Expected denial. Run each SELECT or INSERT separately.
SELECT ORDER_ID FROM DLC_RBAC_DB.RAW.ORDERS_INBOX;
INSERT INTO DLC_RBAC_DB.REPORTING.ORDERS SELECT 999, 1 WHERE FALSE;
USE ROLE DLC_RBAC_INGEST;
USE SECONDARY ROLES NONE;
USE WAREHOUSE DLC_RBAC_WH;
-- Expected denial.
SELECT ORDER_ID FROM DLC_RBAC_DB.RAW.ORDERS_INBOX;
USE ROLE DLC_RBAC_QA;
USE SECONDARY ROLES NONE;
USE WAREHOUSE DLC_RBAC_WH;
-- Expected denial before step 10.
SELECT CHECK_NAME, RESULT FROM DLC_RBAC_DB.QA.LOAD_CHECKS;10. Diagnose and repair the missing schema grant
Record CURRENT_ROLE from the failing session. As SECURITYADMIN, show the grants on the schema and table. The QA role should already hold table SELECT. If the table name and warehouse are correct, complete the path by adding USAGE on the QA schema.
Retry as the same QA role, again with secondary roles off. The original query should now return Sales total / PASS. Changing to SYSADMIN would skip the test of the actual repair.
SELECT CURRENT_ROLE() AS FAILING_ROLE;
USE ROLE SECURITYADMIN;
SHOW GRANTS ON SCHEMA DLC_RBAC_DB.QA;
SHOW GRANTS ON TABLE DLC_RBAC_DB.QA.LOAD_CHECKS;
GRANT USAGE ON SCHEMA DLC_RBAC_DB.QA TO ROLE DLC_RBAC_QA;
SHOW GRANTS TO ROLE DLC_RBAC_QA;
USE ROLE DLC_RBAC_QA;
USE SECONDARY ROLES NONE;
USE WAREHOUSE DLC_RBAC_WH;
SELECT CHECK_NAME, RESULT FROM DLC_RBAC_DB.QA.LOAD_CHECKS;Hands-on lab · Grow, audit and remove access
A grant is part of the life of a dataset. Try the same role on tables created before and after a grant rule, then prove that revoking membership removes the intended path.
11. Cover existing and future tables
As SYSADMIN, create ORDERS_ARCHIVE with order 100. As SECURITYADMIN, set SELECT on FUTURE TABLES for the reporting reader. This defines the starting grants for new tables in REPORTING. The analyst can still read ORDERS from step 5. The archive exists already and should fail. Run that query separately.
Apply SELECT on ALL TABLES in the reporting schema to cover the archive and any other existing lab tables there. SYSADMIN then creates ORDERS_DAILY with order 104. Expect archive 100 / 20 and daily 104 / 35. Compare SHOW GRANTS ON TABLE with SHOW FUTURE GRANTS IN SCHEMA to distinguish grants on real objects from future rules.
Use an ALL or FUTURE rule only in a schema whose tables share the same access policy. Views have their own object type and need the corresponding view grants. For future grants on the same object type, a schema rule takes precedence over a database rule, even when the grantees differ.
USE ROLE SYSADMIN;
USE WAREHOUSE DLC_RBAC_WH;
CREATE TABLE DLC_RBAC_DB.REPORTING.ORDERS_ARCHIVE (ORDER_ID NUMBER, AMOUNT NUMBER);
INSERT INTO DLC_RBAC_DB.REPORTING.ORDERS_ARCHIVE VALUES (100, 20);
USE ROLE SECURITYADMIN;
GRANT SELECT ON FUTURE TABLES IN SCHEMA DLC_RBAC_DB.REPORTING
TO DATABASE ROLE DLC_RBAC_DB.REPORT_READER;
SHOW FUTURE GRANTS IN SCHEMA DLC_RBAC_DB.REPORTING;
USE ROLE DLC_RBAC_ANALYST;
USE SECONDARY ROLES NONE;
USE WAREHOUSE DLC_RBAC_WH;
-- Expected denial. Run this statement separately.
SELECT ORDER_ID, AMOUNT FROM DLC_RBAC_DB.REPORTING.ORDERS_ARCHIVE;
USE ROLE SECURITYADMIN;
GRANT SELECT ON ALL TABLES IN SCHEMA DLC_RBAC_DB.REPORTING
TO DATABASE ROLE DLC_RBAC_DB.REPORT_READER;
USE ROLE SYSADMIN;
USE WAREHOUSE DLC_RBAC_WH;
CREATE TABLE DLC_RBAC_DB.REPORTING.ORDERS_DAILY (ORDER_ID NUMBER, AMOUNT NUMBER);
INSERT INTO DLC_RBAC_DB.REPORTING.ORDERS_DAILY VALUES (104, 35);
USE ROLE SECURITYADMIN;
SHOW GRANTS ON TABLE DLC_RBAC_DB.REPORTING.ORDERS_DAILY;
USE ROLE DLC_RBAC_ANALYST;
USE SECONDARY ROLES NONE;
USE WAREHOUSE DLC_RBAC_WH;
SELECT ORDER_ID, AMOUNT FROM DLC_RBAC_DB.REPORTING.ORDERS_ARCHIVE;
SELECT ORDER_ID, AMOUNT FROM DLC_RBAC_DB.REPORTING.ORDERS_DAILY;12. Audit the assignment, inheritance and future rules
Mira uses SECURITYADMIN. TO USER starts at the identity. TO ROLE starts at the role’s grants. OF ROLE looks in the other direction to see who received that role. INCLUDE HIERARCHY expands the inspection to inherited grants. Read grantee_name to see who actually holds each privilege.
Look for the analyst membership on Ana and the engineer membership on the lab operator. The account analyst role has warehouse access. The inherited database role holds REPORTING table SELECT. The ingest role is granted to ENGINEER, the disabled service user and the lab operator. Separate roles a user can activate from the roles active in a specific session.
Keep the grant and the corresponding approval with the ticket. Authorized reviewers can use GRANTS_TO_ROLES and GRANTS_TO_USERS in Account Usage for history when available to their role. Account Usage can lag. Use SHOW commands for current incident checks.
USE ROLE SECURITYADMIN;
SHOW GRANTS TO USER DLC_RBAC_ANA INCLUDE HIERARCHY;
-- Replace DLC_RBAC_TESTER with the existing lab operator.
SHOW GRANTS TO USER DLC_RBAC_TESTER;
SHOW GRANTS TO ROLE DLC_RBAC_ANALYST INCLUDE HIERARCHY;
SHOW GRANTS TO DATABASE ROLE DLC_RBAC_DB.REPORT_READER;
SHOW GRANTS OF ROLE DLC_RBAC_INGEST;
SHOW FUTURE GRANTS TO ROLE DLC_RBAC_ANALYST INCLUDE HIERARCHY;
SHOW GRANTS TO ROLE PUBLIC INCLUDE HIERARCHY;13. Revoke access, verify and clean up the lab
Confirm you are in the approved practice account and that the names belong to this run. SECURITYADMIN removes SELECT on the original ORDERS table. Leave the table and the analyst membership in place for this check. Run the original read as the analyst with secondary roles off. It should now fail. Run the denial by itself.
If the read still works, stop and look for another grant or inheritance path. Then remove the direct role memberships and verify their removal with SHOW. The operator still holds administrative roles for cleanup. Revoke the future rule separately. This stops new grants and leaves privileges already attached to current objects. Dropping the disposable database removes those lab objects and the database role. SYSADMIN drops only the lab database and warehouse. USERADMIN then drops the four disabled users and custom account roles that it created. Role deletion removes the remaining lab role edges.
Expect no matching lab database, warehouse, users or roles at the end. For a partial run, use SHOW to identify what was actually created and clean up only those confirmed lab resources. Close the lab worksheet after verification.
USE ROLE SECURITYADMIN;
USE SECONDARY ROLES NONE;
REVOKE SELECT ON TABLE DLC_RBAC_DB.REPORTING.ORDERS
FROM DATABASE ROLE DLC_RBAC_DB.REPORT_READER;
USE ROLE DLC_RBAC_ANALYST;
USE SECONDARY ROLES NONE;
USE WAREHOUSE DLC_RBAC_WH;
-- Run alone. Expected to fail after SELECT is removed.
SELECT ORDER_ID, AMOUNT FROM DLC_RBAC_DB.REPORTING.ORDERS;
USE ROLE SECURITYADMIN;
-- Replace DLC_RBAC_TESTER with the existing lab operator.
REVOKE ROLE DLC_RBAC_ANALYST FROM USER DLC_RBAC_TESTER;
REVOKE ROLE DLC_RBAC_ANALYST FROM USER DLC_RBAC_ANA;
SHOW GRANTS TO USER DLC_RBAC_TESTER;
SHOW GRANTS TO USER DLC_RBAC_ANA;
REVOKE ROLE DLC_RBAC_ENGINEER FROM USER DLC_RBAC_TESTER;
REVOKE ROLE DLC_RBAC_QA FROM USER DLC_RBAC_TESTER;
REVOKE ROLE DLC_RBAC_INGEST FROM USER DLC_RBAC_TESTER;
REVOKE SELECT ON FUTURE TABLES IN SCHEMA DLC_RBAC_DB.REPORTING
FROM DATABASE ROLE DLC_RBAC_DB.REPORT_READER;
SHOW FUTURE GRANTS IN SCHEMA DLC_RBAC_DB.REPORTING;
USE ROLE SYSADMIN;
DROP DATABASE DLC_RBAC_DB;
DROP WAREHOUSE DLC_RBAC_WH;
SHOW DATABASES LIKE 'DLC_RBAC_DB';
SHOW WAREHOUSES LIKE 'DLC_RBAC_WH';
USE ROLE USERADMIN;
DROP USER DLC_RBAC_ANA;
DROP USER DLC_RBAC_RAVI;
DROP USER DLC_RBAC_QUINN;
DROP USER DLC_RBAC_ETL_SVC;
DROP ROLE DLC_RBAC_ANALYST;
DROP ROLE DLC_RBAC_ENGINEER;
DROP ROLE DLC_RBAC_QA;
DROP ROLE DLC_RBAC_INGEST;
USE ROLE SECURITYADMIN;
SHOW USERS LIKE 'DLC_RBAC_%';
SHOW ROLES LIKE 'DLC_RBAC_%';Apply the design in a real project
The checks below use the same example names. In production, use the exact identity, role and object from the incident. Run inspection with an approved reviewing role. Apply changes only after approval from the responsible owner.
Grant history answers who received permission. Query History shows the statement and its outcome. Login History shows sign-in attempts. Access History can show recorded data access at object and column level on Enterprise Edition or higher when the viewer has the required access. These sources answer different questions.
Audit access and troubleshoot a failing session →
The user has SELECT and the query fails
In the failing session, record SELECT CURRENT_ROLE(), CURRENT_SECONDARY_ROLES(), CURRENT_WAREHOUSE();. Ask the reviewer to run SHOW GRANTS ON TABLE DLC_RBAC_DB.QA.LOAD_CHECKS; and SHOW GRANTS ON SCHEMA DLC_RBAC_DB.QA;. Confirm the table’s full name and the database and warehouse privileges too.
In the lab the reviewer finds table SELECT and no schema USAGE. Grant USAGE ON SCHEMA DLC_RBAC_DB.QA TO ROLE DLC_RBAC_QA with the GRANT command from step 10. Retry exactly the original read and confirm it returns PASS. A broad parent role could hide the missing path.
The order load fails after a new table appears
Suppose a deployment changes the job target to RAW.ORDERS_INBOX_V2. Check the failed statement and confirm the job still uses INGEST. Run SHOW GRANTS ON TABLE DLC_RBAC_DB.RAW.ORDERS_INBOX_V2; and SHOW FUTURE GRANTS IN SCHEMA DLC_RBAC_DB.RAW;. Confirm what actually exists. The replacement name is a production example and is outside this lab’s setup.
If INSERT is missing, the authorized grant manager can run GRANT INSERT ON TABLE DLC_RBAC_DB.RAW.ORDERS_INBOX_V2 TO ROLE DLC_RBAC_INGEST;. If every future table in an approved landing schema needs the same access, consider the corresponding future INSERT rule at that scope. Retry one controlled job attempt and confirm one row arrives. Check for a prior successful write before replaying a batch.
A new employee joins Analytics
Check the new user’s identity and the approved analytics group. Use SHOW GRANTS TO USER DLC_RBAC_ANA; as the example membership check. Grant the existing analyst role and set the default as in steps 6 and 7. Use the company’s identity-provider workflow when it manages membership.
Have the analyst test the report and verify that the raw inbox stays out of reach. Reuse the reviewed role bundle so the access review has one consistent definition.
An employee changes teams or leaves
Inspect the user’s grants and their inherited paths with SHOW GRANTS TO USER DLC_RBAC_ANA INCLUDE HIERARCHY;. For a transfer, approve the new role, change the default to an assigned role and remove the old membership, for example REVOKE ROLE DLC_RBAC_ANALYST FROM USER DLC_RBAC_ANA;. Check any groups that could reapply the membership.
Confirm the new duties work and the old role no longer provides access. For a departure, disable the approved identity and remove memberships through the managed offboarding flow. ALTER USER DLC_RBAC_ANA SET DISABLED = TRUE; requires authority on that user. Disabling an existing user terminates their running queries. Verify the disabled setting and review remaining grants, tokens and identity-provider access.
Developers need read-only production access
Identify the columns and rows needed for diagnosis. If a support view is sufficient, grant SELECT on that approved view. In this lab the table is approved for the fictional report reader. For dedicated production support, give an approved developer reader role only its report access bundle and warehouse USAGE. Keep deployment and data modification on separate roles.
Before attaching the reader bundle, run SHOW GRANTS TO ROLE DLC_RBAC_ENGINEER INCLUDE HIERARCHY; to see why ENGINEER is unsuitable as a read-only role. Its raw INSERT comes from INGEST. Inspect the proposed support role the same way, then prove the approved read and a write denial. If sensitive columns or rows need narrower exposure, review masking or row access policies and their edition requirements.
A service user has more access than the job needs
Start with SHOW GRANTS TO USER DLC_RBAC_ETL_SVC INCLUDE HIERARCHY;. Suppose someone also assigned ENGINEER. That adds raw SELECT. Confirm the scheduler connects as INGEST and the insert test works. Then the approved grant manager can run REVOKE ROLE DLC_RBAC_ENGINEER FROM USER DLC_RBAC_ETL_SVC; if that membership exists.
Review direct user grants, secondary-role settings and other inherited paths before closing the ticket. Check that the job still appends and cannot read. Assess earlier use in history if the access was unintended.
A role inherits a permission that nobody expected
Start with SHOW GRANTS TO ROLE DLC_RBAC_ENGINEER INCLUDE HIERARCHY;. Locate the row with the unexpected operation and record its grantee_name. Then use SHOW GRANTS OF ROLE DLC_RBAC_INGEST; to trace who inherits the raw writer. Check PUBLIC separately if the grant appears shared.
If the role edge was a mistake, replace the bundle with the narrow permission the job uses before removing the edge. The removal syntax is REVOKE ROLE DLC_RBAC_INGEST FROM ROLE DLC_RBAC_ENGINEER;. Only make that change if the approved design no longer requires raw insert. Retest each affected job because a role edge can supply more than one privilege.
Explain RBAC in an interview
Try each question aloud. Name the decision you would make, give the reason and say what you would check in Snowflake.
Beginner · What is RBAC and why use it?
“I give the reporting permissions to a role and assign that role to the analysts. That gives everyone who needs the same report the same access. When somebody changes jobs I can review or remove that membership in one place.”
Beginner follow-up · Why can I sign in and still get denied?
“The sign-in proves my identity. The query still needs authority to use the warehouse, reach the database and schema, and read the table. I would check the active role and the resource named in the failed query first.”
SQL · How do you connect the reporting bundle to analysts?
“I grant the database role to an account role that the analyst can activate. The reporting role holds schema usage and table select, and the account role holds warehouse usage. I would verify both grants before testing the read.”
GRANT DATABASE ROLE DLC_RBAC_DB.REPORT_READER TO ROLE DLC_RBAC_ANALYST;
GRANT ROLE DLC_RBAC_ANALYST TO USER DLC_RBAC_ANA;
SHOW GRANTS TO ROLE DLC_RBAC_ANALYST INCLUDE HIERARCHY;Intermediate · Does the default role grant access?
“It chooses the starting role. I still need an actual role assignment. I would look at the user’s grants, then check the session because the client can request a different role. I turn secondary roles off when I want to prove what one role provides. Its inherited and PUBLIC privileges still count.”
Intermediate follow-up · Will a future grant fix a table created yesterday?
“I would grant the privilege on yesterday’s table explicitly. A future grant defines what new tables receive. If both database and schema future rules exist for tables in that schema, the schema rule takes precedence. I would test one table from each side of the change.”
Experienced · Why can an insert-only service read the raw table?
“I would capture the service connection’s primary and secondary roles. Then I would check the grant tree and direct grants on the user. If ENGINEER supplied SELECT, I would confirm the job can still write through INGEST, remove the extra membership and repeat both the permitted insert and denied read.”
Experienced follow-up · How would you share only approved rows or columns?
“I would start with a narrowly granted view if it can serve the report. If a shared table needs a consistent rule for which rows each team can see, I would evaluate a row access policy. For a column such as email, I would evaluate masking to change which values the team sees. I’d check edition support and test with real allowed and denied roles.”
Words used in this lesson
- RBAC
- Role-based access control. Grant object privileges to roles and grant the roles to people or workloads.
- Privilege
- Permission to do a particular action, such as reading a table with SELECT.
- Inheritance
- A parent role receives the permissions of the roles granted to it.
See how it works
Choose a step to explore the idea at your own pace.
Open the interactive explanation
Choose system roles and build a custom RBAC hierarchy
Give Ana a report role
One role assignment joins Ana to the reporting access bundle.
Automatic playback is off for reduced motion. Select any step or use Previous and Next. Illustrations explain behavior; they are not live measurements.
Read the complete diagram explanation
- Give Ana a report role
One role assignment joins Ana to the reporting access bundle.
Ana → DLC_RBAC_ANALYST → REPORT_READER
- Keep the job scoped
The engineer inherits the ability to insert from INGEST. INGEST does not inherit the engineer’s SELECT.
Raw INSERT → DLC_RBAC_INGEST → DLC_RBAC_ENGINEER
Try the SQL or command
Read → predict → run in your learning environment → compare. You can also learn by reading without an account.
New to SQL? Where to run it and how to read it
A query is a question written in SQL. Snowflake runs it and returns a result table. This website shows examples; it does not connect to your account.
- No account yet? Read and predict the output first. Follow the account and Snowsight lesson when you are ready.
- For SQL practice, use a learning account in Snowsight and select an authorized role and warehouse. A role determines permissions; a warehouse supplies processing power. Follow the example’s database/schema setup when it refers to stored objects.
- Read the entire example, including comments beginning with
--. Run the selected statement or labeled block in the stated order. Examples labeled Python, shell or HTTP belong in that client, not in a SQL editor. - Compare values and row counts with the explained result. If an example deliberately causes an error, follow its rollback and cleanup steps before continuing.
- SELECT / FROM
- Choose the values to return / identify their input.
- VALUES / COLUMN1
- VALUES supplies tiny example rows. COLUMN1 means their first column, COLUMN2 their second.
- AS / WITH
- AS gives a result a readable name. WITH names a temporary query step within one statement.
- NULL / ::
- NULL means missing or unknown. The :: notation converts a value to a named data type.
- Session
- One connection and its settings. Keep related transaction steps in the same session.
- Database.schema.table
- A full address for stored data. It is separate from the warehouse that processes queries.
Need the L2_OBJECTS_LAB setup? Open the first database-object lesson →
Help with common practice errors
- No active warehouse: select a warehouse your role can use. Do not assume you need to create a new one.
- Object missing or not authorized: check the full name, required setup and active role. Ask the account owner for access if needed.
- Object already exists: setup may already have run. Read the current state or choose a fresh lab name consistently; do not add OR REPLACE blindly.
- Different result: check whether an earlier INSERT or UPDATE changed the data. VALUES examples provide their own fresh input for each statement.
Read the isolated session context
USE SECONDARY ROLES NONE;
SELECT CURRENT_USER() AS SIGNED_IN_USER,
CURRENT_ROLE() AS PRIMARY_ROLE,
CURRENT_SECONDARY_ROLES() AS SECONDARY_ROLES,
CURRENT_WAREHOUSE() AS ACTIVE_WAREHOUSE;What to expect and why
Use a fresh worksheet. The primary role and warehouse reflect the current session. The secondary role setting should be NONE. Use the 13 steps in the article to run the enterprise lab.
Check your understanding
Choose an answer, then check your reasoning. This is practice, not a scored test.
Try it yourself
Ana can read the report. Quinn has SELECT on QA.LOAD_CHECKS and cannot read it. Which grant should you inspect first after confirming the warehouse and database?
Compare your reasoning
Check USAGE on the QA schema as the missing path dependency. Add that one grant if approved and retry the same SELECT under DLC_RBAC_QA with secondary roles disabled.
Official sources and curriculum
Module 17 · See module scope
By Rohit Ray · Independent educational lesson · Explore this visual lab