Back to Utils
Snowflake · View
system_role_usage
All statements executed under ACCOUNTADMIN, SYSADMIN or SECURITYADMIN, including failed attempts. Useful for audits and detecting unexpected use of admin roles.
Source: SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY · Latency: ~45min
| Column | Description |
|---|---|
| date | Date |
| user_name | User |
| role_name | System role used |
| query_type | e.g. SELECT, ALTER, GRANT |
| execution_status | SUCCESS, FAIL or INCIDENT |
| statement | Full query text |
Source code
create_admin_views.sql
create or replace view system_role_usage
comment = 'Statements executed under ACCOUNTADMIN, SYSADMIN or SECURITYADMIN, including failed attempts (source: SNOWFLAKE.ACCOUNT_USAGE)'
as
select start_time::date as date
, user_name
, role_name
, query_type
, execution_status
, query_text as statement
from snowflake.account_usage.query_history
where upper(role_name) in ('ACCOUNTADMIN', 'SYSADMIN', 'SECURITYADMIN')
order by start_time desc;