What you will be able to do
- Pick the narrowest privilege that lets a role do a given task on a database, schema, table, stage, function or warehouse
- Tell object privileges apart from global (account) privileges such as MANAGE GRANTS, CREATE ROLE and CANCEL QUERY
- Use SHOW ROLES, SHOW USERS and the SHOW GRANTS variants to find out who holds what, and predict what each one shows to a role without admin rights
- Audit sign-ins, sessions and queries with the ACCOUNT_USAGE views, and pick the SNOWFLAKE database role an auditor needs
Key concept
Privilege on an object, held by a role — In Snowflake, a privilege is always granted on one specific object (or on the account) to a role, and users get it by being granted that role. The same privilege name can allow different things on different object types. To work out what a user can do, you look at the role, then the object, then the privilege.
1.How a privilege attaches to a role and an object
Every grant in Snowflake has three parts: a privilege, the object it applies to, and the role that receives it. Users never hold object privileges directly in the normal model. They get them through the roles granted to them. That is why access reviews, covered later on this page, always come back to roles.
A privilege name is not a fixed capability. MONITOR on a warehouse shows its queries and usage. MONITOR on a user, task or database shows details of that object instead. USAGE on a schema lets a role use the schema and list what is in it, while USAGE on a function lets a role call it. Not every object type accepts every privilege, so a grant that reads well in English can be invalid for the object you named. To get the definitive list of privileges an object accepts, call EXPLAIN_GRANTABLE_PRIVILEGES rather than guessing.
OWNERSHIP is the exception to the grant-it-yourself pattern. Snowflake gives it automatically to the role that created the object. It covers dropping, altering, renaming and granting or revoking access on the object. The owning role can hand it to another role with GRANT OWNERSHIP, and so can any role with MANAGE GRANTS. If a role can drop a table that nobody explicitly granted it rights on, look first at who created the table.
Checkpoint 1 of 9· Check yourself
The role ETL_ROLE can drop and rename the table SALES.RAW.ORDERS, but no administrator ever ran a GRANT that gave ETL_ROLE any privilege on that table. What is the most likely explanation?
Nobody has to grant OWNERSHIP. Snowflake gives it to the role that created the object, and it covers dropping, altering and renaming. When a role has rights that nobody granted it, check first which role created the object. Users don't hold object privileges directly, and USAGE and MONITOR only let a role use or view an object. Neither one lets it drop anything.
“OWNERSHIP is a special privilege on an object that is automatically granted to the role that created the object”Source: docs.snowflake.com
Sources1
2.Which privileges each object type accepts
Containers, data objects and executable objects each take a different set of privileges. Databases and schemas take USAGE to enter them, CREATE <object_type> to add objects inside them, and MODIFY and MONITOR for their settings and details. Tables take the DML verbs. Stages split by kind: internal stages use READ and WRITE, and external stages use USAGE. A role that loads from an internal stage with COPY INTO <table> needs READ on that stage. USAGE on an internal stage is not a privilege that applies.
| Object type | Privileges | What they allow |
|---|---|---|
| Database, Schema | USAGE, CREATE <object_type>, MODIFY, MONITOR | USE and SHOW on the container; create objects inside it; change its settings; see its details |
| Table | SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES | Run the matching statement; REFERENCES shows the structure but not the data |
| View, Materialized View | SELECT, REFERENCES | Query it; see its structure |
| Stage (internal only) | READ, WRITE | READ for GET, LIST and COPY INTO <table>; WRITE for PUT, REMOVE and COPY INTO <location> |
| Stage (external only), File Format, Sequence | USAGE | Use the object in statements |
| User-Defined Function, Stored Procedure, External Function | USAGE | Execute the routine |
| Task | MONITOR, OPERATE | See details; suspend or resume it |
REFERENCES is easy to misread. It lets a role see a table's structure, but not its data. It also lets the role point a foreign key at the table as the unique or primary key side. A role with REFERENCES and no SELECT can describe the columns of a table but cannot read a single row.
Warehouses show most clearly how close privileges can sit while doing different jobs. OPERATE controls the warehouse's state: start, stop, suspend and resume. It also lets the role view current and past queries and abort any query that is running. MODIFY covers every property, including size. That is the one to withhold when a role must not resize the warehouse or change its auto-suspend setting. MONITOR only lets the role look at queries and usage statistics, and USAGE only lets it run queries on the warehouse.
| Privilege | Change state (suspend/resume) | Abort running queries | Change size or properties | View queries and usage |
|---|---|---|---|---|
| USAGE | No | No | No | No |
| MONITOR | No | No | No | Yes |
| OPERATE | Yes | Yes | No | Yes |
| MODIFY | No | No | Yes | No |
Checkpoint 2 of 9· Check yourself
A data engineer grants USAGE on the internal stage @RAW_FILES to LOADER_ROLE. LOADER_ROLE then runs COPY INTO a table from that stage. Which grant on the stage does LOADER_ROLE need for the load to work?
Internal stages accept READ and WRITE, not USAGE. Loading into a table with COPY INTO reads from the stage, so it needs READ. WRITE covers PUT, REMOVE and unloading with COPY INTO a location. USAGE applies only to external stages.
“Grants the ability to perform any operations that require reading from an internal stage (GET, LIST, COPY INTO <table>, etc.)”Source: docs.snowflake.com
Checkpoint 3 of 9· Exam question
A role named LOAD_OPS runs nightly batch jobs and must be able to suspend and resume the warehouse ETL_WH around each run and abort stuck queries on it. It must not be able to resize the warehouse or change its auto-suspend setting. Which grant is the MOST appropriate?
Correct answer: B — GRANT OPERATE ON WAREHOUSE etl_wh TO ROLE load_ops, which allows suspend, resume and aborting queries without changing properties
- A. MODIFY permits changing warehouse properties such as size and AUTO_SUSPEND, which is exactly what the role must not do. It also does not on its own cover starting, stopping or aborting queries.
- B. OPERATE lets a role change the warehouse state (start, stop, suspend, resume) and view and abort queries running on it. It does not allow altering size or auto-suspend, so it matches the requirement exactly.
- C. MONITOR is read-only visibility into queries and usage on the warehouse. It cannot suspend, resume or abort anything, so the batch job would still fail.
- D. USAGE only allows running queries on the warehouse (and triggering auto-resume). It does not permit an explicit ALTER WAREHOUSE ... SUSPEND or RESUME, nor aborting other sessions' queries.
3.Global privileges are granted on the account
Some privileges do not belong to any single object. They are granted ON ACCOUNT and apply to the whole account. CREATE ROLE, CREATE USER, CREATE DATABASE and CREATE WAREHOUSE live here, as do the APPLY ... POLICY family and the monitoring privileges. Several of them, including CREATE DATABASE, CREATE WAREHOUSE and MONITOR USAGE, must be granted by ACCOUNTADMIN. Delegating those is an ACCOUNTADMIN decision, not a SECURITYADMIN one.
MANAGE GRANTS is the global privilege behind delegated administration. It lets a role grant or revoke privileges on objects it does not own, acting as if it were the owner. SECURITYADMIN holds it account-wide by default. A custom role that needs the same reach needs MANAGE GRANTS granted to it. OWNERSHIP of many objects is not a substitute. MANAGE GRANTS can also be granted on a single database or schema, which limits that power to the container and the objects in it.
Several global privileges are close to an object privilege but reach further. CANCEL QUERY cancels queries run by any user in the account, while OPERATE on a warehouse only aborts queries on that warehouse. MONITOR USAGE shows usage and history for databases and warehouses across the account. MONITOR USER and MONITOR ROLE let a role view users or roles across the account without being able to change them. When a task concerns one object, grant the object privilege. Reach for the global privilege only when the task really is account-wide.
Checkpoint 4 of 9· Check yourself
An on-call support role has to cancel runaway queries from any user, on any warehouse in the account. It must not be able to suspend, resume or resize warehouses. Which grant fits?
CANCEL QUERY is a global privilege that cancels queries run by any user in the account, and it gives no control over warehouse state. OPERATE would also let the role suspend and resume warehouses. MONITOR USAGE only shows usage and history. MANAGE GRANTS lets a role grant and revoke privileges, not cancel queries.
“Grants the ability to cancel queries executed by any user in the account.”Source: docs.snowflake.com
Sources1
4.Listing roles and users with SHOW ROLES and SHOW USERS
SHOW ROLES lists system-defined and custom roles, but only the ones your current role can see. It returns roles on which your current role holds at least one privilege. MANAGE GRANTS lets its holder see every object, so by default only ACCOUNTADMIN and SECURITYADMIN get the full list. Seeing a role's name gives no access: being able to list a role is not the same as being able to use it.
Each row describes one role: its owner, whether it is your default or current role, and three counts. assigned_to_users counts users, granted_to_roles counts roles that hold it, and granted_roles counts roles it holds. These are numbers, not names. A row showing ANALYST with granted_to_roles of 6 tells you six roles hold it, not which six. LIKE, STARTS WITH and LIMIT ... FROM narrow or page through the output, and the command needs no running warehouse.
SHOW ROLES LIMIT 10 FROM 'my_role2';SHOW USERS filters by column instead of by row. Every user's name always appears. The rest of the columns are filled in only if the active role has OWNERSHIP of that user or MANAGE GRANTS on the account, and otherwise they are NULL. Those columns are what an access reviewer needs: disabled, type, has_password, has_rsa_public_key, has_mfa, has_pat, default_role and last_success_login. Note that default_role is the only role it reports. SHOW USERS does not list the roles granted to a user.
Checkpoint 5 of 9· Check yourself
During an access review, an auditor works in the custom role AUDIT_ROLE. SHOW ROLES returns only a few of the account's roles. SHOW USERS lists every username, but columns such as has_mfa and disabled are NULL. Which single grant to AUDIT_ROLE fixes both outputs?
SHOW ROLES returns only the roles your current role holds a privilege on. MANAGE GRANTS lets its holder see every object, and SHOW USERS fills in the other columns only for OWNERSHIP of the user or MANAGE GRANTS on the account. Granting AUDIT_ROLE all the other roles would show more roles, but the SHOW USERS columns would stay NULL, and it would give the auditor those roles' access. CREATE privileges do not make existing objects visible. SHOW commands do not need a running warehouse.
“The MANAGE GRANTS access privilege implicitly allows its holder to see every object in the account.”Source: docs.snowflake.com
Sources3
5.Inspecting grants with SHOW GRANTS ON, TO and OF
SHOW GRANTS lists privileges that have been explicitly granted to roles, users and shares. The keyword after GRANTS decides which way you are looking. Run without a keyword, it is the same as SHOW GRANTS TO USER current_user and lists the roles you hold.
| Command | Answers |
|---|---|
| SHOW GRANTS ON ACCOUNT | Which roles hold global (account-level) privileges? |
| SHOW GRANTS ON <object_type> <object_name> | Who holds which privileges on this object? |
| SHOW GRANTS TO ROLE <role_name> | What has this role been granted: privileges and the roles it holds? |
| SHOW GRANTS TO USER <user_name> | What has been granted to this user? |
| SHOW GRANTS OF ROLE <role_name> | Which users and roles has this role been granted to? |
| SHOW FUTURE GRANTS IN SCHEMA <schema_name> | Which grants will apply to objects created in this schema later? |
TO and OF point in opposite directions, and mixing them up gives you the wrong answer. SHOW GRANTS TO ROLE finance_analyst looks into the role: the database USAGE, table SELECT and other privileges it holds. SHOW GRANTS OF ROLE finance_analyst looks out from the role and lists every user and every role it has been granted to. After a reorganization, OF is the command to use when you need to find which accounts and parent roles still carry a role. Each row's granted_to column says USER or ROLE, and grantee_name names the holder.
SHOW GRANTS OF ROLE analyst;SHOW GRANTS ON ACCOUNT. CREATE DATABASE is a global privilege, so it is granted on the account and only shows up in the account-level listing.
Checkpoint 6 of 9· Match them up
Match each SHOW GRANTS variant to the access-review question it answers.
Tap a term, then the definition that fits it.
ON looks at a target (the account or one object) and lists who holds privileges on it. TO looks into a role and lists what it has been granted. OF looks out from a role and lists the users and roles it has been granted to. People often mix up TO and OF, and doing so in an access review returns the wrong list.
“Lists all privileges that have been granted on the object.”Source: docs.snowflake.com
Checkpoint 7 of 9· Exam question
After a reorganization, a security reviewer must list every user and every role that has been granted the custom role FINANCE_ANALYST, so access can be removed from the right accounts. Which command returns this information?
Correct answer: D — SHOW GRANTS OF ROLE finance_analyst, which lists each user and role that the role has been granted to
- A. SHOW GRANTS TO ROLE lists what the role holds (privileges and roles granted to it), not who holds the role. It answers the opposite question.
- B. SHOW ROLES includes counts such as assigned_to_users, but only counts, not the names of the users or roles that were granted the role.
- C. SHOW USERS filters on user names, not role membership, and its output shows default_role rather than a complete list of granted roles.
- D. SHOW GRANTS OF ROLE returns the grantees of the role: every user and role to which it has been granted. That is the list the reviewer needs for revocation.
Sources4
6.Auditing logins, sessions and queries in ACCOUNT_USAGE
SHOW commands describe current state. Questions about history, such as who signed in, how, and what they ran, are answered from the views in SNOWFLAKE.ACCOUNT_USAGE. These views trade freshness for depth. They keep dropped objects and a year of history, but their data arrives with a delay.
| Property | ACCOUNT_USAGE | INFORMATION_SCHEMA |
|---|---|---|
| Includes dropped objects | Yes | No |
| Latency | 45 minutes to 3 hours, by view | None |
| History retained | 1 year | 7 days to 6 months, by view or function |
| Login history | LOGIN_HISTORY view: 2 hours latency, 1 year | LOGIN_HISTORY table function: last 7 days only |
Pick the source based on how far back the question goes. The INFORMATION_SCHEMA.LOGIN_HISTORY table function returns login activity from the last 7 days only. If you ask it for a time range outside that window, it returns an error. A four-month investigation into password guessing therefore needs ACCOUNT_USAGE.LOGIN_HISTORY. Each row there is one login attempt, with USER_NAME, CLIENT_IP, REPORTED_CLIENT_TYPE, FIRST_AUTHENTICATION_FACTOR, SECOND_AUTHENTICATION_FACTOR, IS_SUCCESS, and an ERROR_CODE and ERROR_MESSAGE when the attempt failed. Filter on is_success = 'NO' and group by user and IP. Treat REPORTED_CLIENT_TYPE with care, because the client reports it and Snowflake does not authenticate it.
select user_name, sum(iff(is_success = 'NO', 1, 0)) as failed_logins, count(*) as logins, sum(iff(is_success = 'NO', 1, 0)) / nullif(count(*), 0) as login_failure_rate from login_history where event_timestamp > date_trunc(month, current_date) group by 1 order by 4 desc;SESSIONS and USERS answer different questions, so they cannot replace LOGIN_HISTORY. SESSIONS returns one row for each session created in the last year, with AUTHENTICATION_METHOD, LOGIN_EVENT_ID and client details. It tells you how successful connections were made, and it records a session only when one was created. USERS is an object view that describes each user, not each attempt. QUERY_HISTORY records what was run, with 45 minutes of latency and one year of retention. Because these views can change over time, select the columns you need rather than SELECT *.
An auditor's role needs read access to these views, and the narrow way to give it is through SNOWFLAKE database roles. A database role is a named set of privileges that lives inside a database rather than at account level. The SNOWFLAKE database defines four for ACCOUNT_USAGE (OBJECT_VIEWER, USAGE_VIEWER, GOVERNANCE_VIEWER and SECURITY_VIEWER), each holding SELECT on a specific group of views. A database role reaches an auditor when ACCOUNTADMIN runs GRANT DATABASE ROLE, which assigns a database role to an account role. The auditor's custom role then carries the view access, and any user granted that account role can query the views. Granting IMPORTED PRIVILEGES on the whole SNOWFLAKE database is broader, which is why database roles are the safer choice. The detail people get wrong is that the views are split across roles. LOGIN_HISTORY, SESSIONS, USERS, ROLES and the GRANTS_TO_* views need SECURITY_VIEWER. QUERY_HISTORY needs GOVERNANCE_VIEWER. An auditor who must cover both sign-ins and queries needs both database roles. The wider setup for giving non-admins this access is in Giving non-admins access to usage and billing data.
For an organization with several accounts, the ORGANIZATION_USAGE schema has its own LOGIN_HISTORY view. It carries the same event columns, including CLIENT_IP, IS_SUCCESS and the authentication factors, so one query can cover every account. How that schema is enabled and governed is covered under ORGANIZATION_USAGE.
Checkpoint 8 of 9· Fill the gap
This ACCOUNT_USAGE query reports failed logins and the failure rate per user for the current month. Which view belongs in the blank?
select user_name, sum(iff(is_success = 'NO', 1, 0)) as failed_logins, count(*) as logins, sum(iff(is_success = 'NO', 1, 0)) / nullif(count(*), 0) as login_failure_rate from ? where event_timestamp > date_trunc(month, current_date) group by 1 order by 4 desc;Each LOGIN_HISTORY row is one login attempt, and its IS_SUCCESS column marks whether the attempt failed, so this view can count failures. SESSIONS only records a session once one has been created, so failed attempts never show up there. USERS has one row per user, not one per attempt. QUERY_HISTORY records the queries that were run, not sign-ins.
Source: docs.snowflake.comCheckpoint 9 of 9· Exam question
The security team suspects password-guessing attacks over the last four months. An administrator must report failed sign-in attempts per user and client IP address for that whole period. Which source is the MOST appropriate?
Correct answer: C — The SNOWFLAKE.ACCOUNT_USAGE.LOGIN_HISTORY view, filtered on is_success = 'NO', which keeps 365 days of login events
- A. The table function only returns events from the last seven days, so most of the four-month window would be missing.
- B. SESSIONS records sessions that were created. Failed authentication attempts never create a session, so they do not appear there.
- C. ACCOUNT_USAGE.LOGIN_HISTORY retains a year of login attempts including client_ip, user_name and error_message, so a filter on is_success = 'NO' covers the full four months.
- D. USERS holds one row per user with summary attributes. It has no per-attempt rows, so it cannot show failed attempts by IP address.
Sources
(10)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“The meaning of each privilege varies depending on the object type to which it is applied, and not all objects support all privileges”
↩︎ How a privilege attaches to a role and an object“To obtain a definitive list of all possible privileges for one or more objects, call the EXPLAIN_GRANTABLE_PRIVILEGES function.”
↩︎ How a privilege attaches to a role and an object“OWNERSHIP is a special privilege on an object that is automatically granted to the role that created the object”
↩︎ How a privilege attaches to a role and an object“Grants the ability to perform any operations that require reading from an internal stage (GET, LIST, COPY INTO <table>, etc.).”
↩︎ Which privileges each object type accepts“Grants the ability to view the structure of an object (but not the data).”
↩︎ Which privileges each object type accepts“Enables granting or revoking privileges on objects for which the role is not the owner.”
↩︎ Global privileges are granted on the account“The SECURITYADMIN role holds account-level MANAGE GRANTS by default.”
↩︎ Global privileges are granted on the account“Grants the ability to cancel queries executed by any user in the account.”
↩︎ Global privileges are granted on the account“Privileges are granted to roles, and roles are granted to users”
↩︎ Key concept“Grants the ability to perform any operations that require reading from an internal stage (GET, LIST, COPY INTO <table>, etc.)”
↩︎ Checkpoint - 2.
“Enables altering any properties of a warehouse, including changing its size.”
↩︎ Which privileges each object type accepts“Enables viewing current and past queries executed on a warehouse as well as usage statistics on that warehouse.”
↩︎ Which privileges each object type accepts“and aborting any executing queries.”
↩︎ Exam trap 1“Enables changing the state of a warehouse (stop, start, suspend, resume)”
↩︎ Prediction - 3.
“The command only returns objects for which the current user’s current role has been granted at least one access privilege.”
↩︎ Listing roles and users with SHOW ROLES and SHOW USERS“The MANAGE GRANTS access privilege implicitly allows its holder to see every object in the account.”
↩︎ Listing roles and users with SHOW ROLES and SHOW USERS“the ability to list roles is not the same as using any role.”
↩︎ Listing roles and users with SHOW ROLES and SHOW USERS“You must use double-quoted identifiers because the output column names for SHOW commands are in lowercase.”
↩︎ Listing roles and users with SHOW ROLES and SHOW USERS - 4.
“Lists all access control privileges that have been explicitly granted to roles, users, and shares.”
↩︎ Inspecting grants with SHOW GRANTS ON, TO and OF“Lists all the account-level (i.e. global) privileges that have been granted to roles.”
↩︎ Inspecting grants with SHOW GRANTS ON, TO and OF“List all roles and users who have been granted the analyst role:”
↩︎ Exam trap 2“Lists all privileges that have been granted on the object.”
↩︎ Checkpoint - 5.
“Certain account usage views provide historical usage metrics. The retention period for these views is 1 year (365 days).”
↩︎ Auditing logins, sessions and queries in ACCOUNT_USAGE“To avoid unintentionally granting access to organization-level data, consider using SNOWFLAKE database roles to grant access to views in the ACCOUNT_USAGE schema.”
↩︎ Auditing logins, sessions and queries in ACCOUNT_USAGE“Grant a SNOWFLAKE database role to an account role.”
↩︎ Auditing logins, sessions and queries in ACCOUNT_USAGE“ACCOUNT_USAGE schemas have four defined SNOWFLAKE database roles, each granted the SELECT privilege on specific views.”
↩︎ Auditing logins, sessions and queries in ACCOUNT_USAGE“LOGIN_HISTORY view | SECURITY_VIEWER”
↩︎ Auditing logins, sessions and queries in ACCOUNT_USAGE“The Snowflake-specific views are subject to change. Avoid selecting all columns from these views.”
↩︎ Auditing logins, sessions and queries in ACCOUNT_USAGE“QUERY_HISTORY view | GOVERNANCE_VIEWER”
↩︎ Exam trap 4 - 6.https://docs.snowflake.com/en/sql-reference/sql-allOfficial docs
“GRANT DATABASE ROLE | Assigns a database role to an account role, another database role, or a user.”
↩︎ Auditing logins, sessions and queries in ACCOUNT_USAGE“SHOW DATABASE ROLES | Lists all the database roles in the specified database.”
↩︎ Auditing logins, sessions and queries in ACCOUNT_USAGE - 7.
“Snowflake returns one row for each session created over the last year.”
↩︎ Auditing logins, sessions and queries in ACCOUNT_USAGE - 8.
“IP address where the request originated.”
↩︎ Auditing logins, sessions and queries in ACCOUNT_USAGE“Whether the user’s request was successful or not.”
↩︎ Auditing logins, sessions and queries in ACCOUNT_USAGE
Also cited
“These functions return login activity within the last 7 days.”
↩︎ Exam trap 3“Otherwise, the other columns contain NULL.”
↩︎ Exam trap 5“Any user can execute the SHOW USERS command. The output always includes the username in the name column.”
↩︎ Prediction