CertSafari
    Snowflake SnowPro Advanced: Administrator (ADA-C02)· Lessons

    Domain 1 · Lesson 3/24

    Auditing Users, Logins and Queries with ACCOUNT_USAGE and ORGANIZATION_USAGE

    Given a scenario, create and manage access control.

    7 min read
    4.43% of exam
    2 sources
    Published 5 Oct 2026
    Docs as of 4 Oct 2026

    What you will be able to do

    • Choose between ACCOUNT_USAGE views and the Information Schema based on dropped objects, latency and retention
    • Give a non-admin role audit access through IMPORTED PRIVILEGES or the narrower SNOWFLAKE database roles
    • Write login-history audit queries and explain who can access the ORGANIZATION_USAGE schema

    1.ACCOUNT_USAGE: the long-term audit record

    The shared SNOWFLAKE database contains an ACCOUNT_USAGE schema with object metadata and historical usage for your account. A READER_ACCOUNT_USAGE schema does the same for any reader accounts you have created. ACCOUNT_USAGE views have the same structure and names as their Information Schema counterparts. Three differences decide which one an audit question needs.

    ACCOUNT_USAGE compared with the Information Schema
    DifferenceACCOUNT_USAGEInformation Schema
    Includes dropped objectsYesNo
    Latency of dataFrom 45 minutes to 3 hours (varies by view)None
    Retention of historical data1 yearFrom 7 days to 6 months (varies by view/table function)

    Because dropped objects stay in the views, an object name can repeat. ID columns tell apart records that share a name, and many object views have a DELETED timestamp. When an object-name column is NULL, the object has been dropped. These views cover the user and query activity this objective asks about.

    ACCOUNT_USAGE views for auditing users and queries
    ViewTypeLatencySNOWFLAKE database role
    QUERY_HISTORYHistorical45 minutesGOVERNANCE_VIEWER
    ACCESS_HISTORY (Enterprise Edition or higher)Historical3 hoursGOVERNANCE_VIEWER
    LOGIN_HISTORYHistorical2 hoursSECURITY_VIEWER
    SESSIONSHistorical3 hoursSECURITY_VIEWER
    USERS / ROLESObject2 hoursSECURITY_VIEWER
    GRANTS_TO_ROLES / GRANTS_TO_USERSObject2 hoursSECURITY_VIEWER

    Checkpoint 1 of 4· Check yourself

    An auditor must find which users ran queries against a table that was dropped four months ago. Where should they look?

    Sources1

    2.Giving an auditor role access to ACCOUNT_USAGE

    Every user can see the SNOWFLAKE database, but its schemas need a grant from a user with ACCOUNTADMIN. There are two ways to give that grant. IMPORTED PRIVILEGES on the SNOWFLAKE database gives broad access in a single statement. SNOWFLAKE database roles are narrower: each one has SELECT on a defined set of ACCOUNT_USAGE views, and you grant it to an account role. Snowflake recommends database roles so that you do not expose organization-level data by accident.

    Granting IMPORTED PRIVILEGES on SNOWFLAKE to SYSADMIN and a custom rolesql
    USE ROLE ACCOUNTADMIN; GRANT IMPORTED PRIVILEGES ON DATABASE SNOWFLAKE TO ROLE SYSADMIN; GRANT IMPORTED PRIVILEGES ON DATABASE SNOWFLAKE TO ROLE customrole1;
    A user holding customrole1 can then query an ACCOUNT_USAGE viewsql
    USE ROLE customrole1; SELECT database_name, database_owner FROM SNOWFLAKE.ACCOUNT_USAGE.DATABASES;
    The four ACCOUNT_USAGE database roles in the SNOWFLAKE database
    Database roleVisibility intoExample views
    OBJECT_VIEWERObject metadataDATABASES, TABLES, VIEWS
    USAGE_VIEWERHistorical usage informationWAREHOUSE_METERING_HISTORY, STORAGE_USAGE
    GOVERNANCE_VIEWERData-governance-related informationQUERY_HISTORY, ACCESS_HISTORY, MASKING_POLICIES
    SECURITY_VIEWERSecurity-based informationLOGIN_HISTORY, USERS, GRANTS_TO_ROLES, SESSIONS

    For an auditor, which database role to grant depends on the question being asked. A role that has SECURITY_VIEWER can read LOGIN_HISTORY, USERS and the GRANTS_TO_* views, but it cannot read QUERY_HISTORY, which belongs to GOVERNANCE_VIEWER. If the auditor needs both logins and queries, grant both database roles. There is also READER_USAGE_VIEWER, which covers the READER_ACCOUNT_USAGE views for reader accounts.

    Checkpoint 2 of 4· Put it in order

    Put the steps for letting customrole1 query ACCOUNT_USAGE in order

    1. 1.USE ROLE customrole1
    2. 2.GRANT IMPORTED PRIVILEGES ON DATABASE SNOWFLAKE TO ROLE customrole1
    3. 3.SELECT database_name, database_owner FROM SNOWFLAKE.ACCOUNT_USAGE.DATABASES
    4. 4.USE ROLE ACCOUNTADMIN

    Sources1

    3.Auditing login activity

    LOGIN_HISTORY is the starting point for user-activity audits. The documented examples calculate failed logins per user and the login failure rate for the month so far. A variant groups by reported_client_type as well, which shows which client the failures came from. Write the query to select only the columns you need. Snowflake may change these views, so avoid SELECT *.

    Failed logins and failure rate by user, month to datesql
    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;

    Checkpoint 3 of 4· Fill the gap

    Which ACCOUNT_USAGE view completes this failed-login audit query?

    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;

    Sources1

    4.ORGANIZATION_USAGE: auditing across accounts

    ACCOUNT_USAGE covers a single account. ORGANIZATION_USAGE, also in the shared SNOWFLAKE database, provides historical usage data for every account in the organization. The schema exists in the organization account and in any regular account where the ORGADMIN role is enabled. By default, only users with GLOBALORGADMIN can query its views in the organization account. To give access to other users, the organization administrator grants an application role, such as SNOWFLAKE.ORG_USAGE_ADMIN, which opens every view in the schema.

    Granting all ORGANIZATION_USAGE views to user joe through a custom rolesql
    USE ROLE GLOBALORGADMIN;
    
    GRANT APPLICATION ROLE SNOWFLAKE.ORG_USAGE_ADMIN TO ROLE custom_role;
    
    GRANT ROLE custom_role TO USER joe;

    When you compare cost-related ACCOUNT_USAGE views with the matching ORGANIZATION_USAGE views, set the session time zone to UTC before querying the ACCOUNT_USAGE view, using ALTER SESSION SET TIMEZONE = UTC;. The sources behind this lesson do not list the individual ORGANIZATION_USAGE views. The per-user login and query views described above are documented in ACCOUNT_USAGE, so audit those there.

    Checkpoint 4 of 4· Fill the gap

    Which application role gives custom_role access to every ORGANIZATION_USAGE view?

    USE ROLE GLOBALORGADMIN;
    
    GRANT APPLICATION ROLE SNOWFLAKE. ?  TO ROLE custom_role;
    
    GRANT ROLE custom_role TO USER joe;

    Sources21

    Exam traps

    Each one states something that sounds right. Open it to see what is actually true.

    1. 1.ACCOUNT_USAGE views show activity in real time, just like the Information Schema.Why is that wrong?

      ACCOUNT_USAGE views lag by between 45 minutes and 3 hours depending on the view. For activity from the last few minutes, use the Information Schema.

      Covered in ACCOUNT_USAGE: the long-term audit record

    2. 2.Granting IMPORTED PRIVILEGES on SNOWFLAKE is the least-privilege way to give an auditor ACCOUNT_USAGE access.Why is that wrong?

      Snowflake recommends SNOWFLAKE database roles such as SECURITY_VIEWER, which limit access to particular views and avoid exposing organization-level data.

      Covered in Giving an auditor role access to ACCOUNT_USAGE

    3. 3.Any ACCOUNTADMIN can query ORGANIZATION_USAGE in the organization account by default.Why is that wrong?

      By default, only users with GLOBALORGADMIN can access those views. Anyone else needs an application role such as ORG_USAGE_ADMIN.

      Covered in ORGANIZATION_USAGE: auditing across accounts

    Practise it for real

    Give a custom role ACCOUNT_USAGE access and run a month-to-date failed-login audit

    1. 1.Run USE ROLE ACCOUNTADMIN; GRANT IMPORTED PRIVILEGES ON DATABASE SNOWFLAKE TO ROLE customrole1;

      Why: SNOWFLAKE schemas can only be queried after a grant from ACCOUNTADMIN.

      You should see: The statements succeed and customrole1 can now read ACCOUNT_USAGE.

    2. 2.Switch with USE ROLE customrole1; and run SELECT database_name, database_owner FROM SNOWFLAKE.ACCOUNT_USAGE.DATABASES;

      Why: This confirms the grant works before you run audit queries.

      You should see: Rows listing databases and the roles that own them.

    3. 3.Run the failed-logins-by-user query against login_history.

      Why: LOGIN_HISTORY records each login attempt along with whether it succeeded.

      You should see: One row per user showing failed_logins, logins and login_failure_rate, highest failure rate first. Activity from the last two hours may not appear yet.

    Stuck? Get a nudge

    If you would rather not grant IMPORTED PRIVILEGES, grant the SNOWFLAKE database role SECURITY_VIEWER to the role instead. It covers LOGIN_HISTORY.

    Sources

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “In the SNOWFLAKE database, the ACCOUNT_USAGE and READER_ACCOUNT_USAGE schemas enable querying object metadata, as well as historical usage data”
      ↩︎ ACCOUNT_USAGE: the long-term audit record
      “If a column for an object name (for example, the TABLE_NAME column) is NULL, that object has been dropped.”
      ↩︎ ACCOUNT_USAGE: the long-term audit record
      “By default, the SNOWFLAKE database is visible to all users”
      ↩︎ Giving an auditor role access to ACCOUNT_USAGE
      “The SECURITY_VIEWER role provides visibility into security-based information.”
      ↩︎ Giving an auditor role access to ACCOUNT_USAGE
      “Avoid selecting all columns from these views.”
      ↩︎ Auditing login activity
      “you must first set the timezone of the session to UTC.”
      ↩︎ ORGANIZATION_USAGE: auditing across accounts
      “For most of the views, the latency is 2 hours (120 minutes).”
      ↩︎ Exam trap 1
      “To avoid unintentionally granting access to organization-level data, consider using SNOWFLAKE database roles to grant access to views in the ACCOUNT_USAGE schema.”
      ↩︎ Exam trap 2
      “In contrast, views/table functions in the Snowflake Information Schema do not have any latency.”
      ↩︎ Prediction
      “Certain account usage views provide historical usage metrics. The retention period for these views is 1 year (365 days).”
      ↩︎ Checkpoint
      “USE ROLE ACCOUNTADMIN; GRANT IMPORTED PRIVILEGES ON DATABASE SNOWFLAKE TO ROLE SYSADMIN;”
      ↩︎ Checkpoint
    2. 2.
      “Snowflake provides historical usage data for all accounts in your organization via the ORGANIZATION_USAGE schema in a shared database named SNOWFLAKE.”
      ↩︎ ORGANIZATION_USAGE: auditing across accounts
      “The ORGANIZATION_USAGE schema is available in the organization account and a regular account that has the ORGADMIN role enabled.”
      ↩︎ ORGANIZATION_USAGE: auditing across accounts
      “By default, only users granted the GLOBALORGADMIN role can access ORGANIZATION_USAGE views in the organization account.”
      ↩︎ Exam trap 3

    Ready to test yourself?

    Practise the 16 questions on this subdomain.

    Spotted a mistake, or was something unclear? Tell us.