Viewing effective privileges
The following code example shows how to view the effective privileges of the current user:Usage examples
The following examples demonstrate how to validate privileges at both the account level and the database level. By running a query against theinformation_schema
views, you can check the effective permissions granted to a user or role. Each scenario includes an example query and output to illustrate the scope of the retrieved privileges.
Validating privileges at the account level
If no database is selected, the query runs at the account level and shows account-scoped privileges. Example In the following code example, a usertest_user
with an account_admin role retrieves their privileges and associated roles for their current user session:
Grantee | role_name | privilege_type | object_type | object_name |
---|---|---|---|---|
test_user | account_admin | MODIFY ANY ENGINE | account | account-1 |
test_user | account_admin | MODIFY ANY DATABASE | account | account-1 |
test_user | account_admin | OPERATE ANY ENGINE | account | account-1 |
test_user | account_admin | MODIFY ANY ROLE | account | account-1 |
test_user | account_admin | USAGE ANY DATABASE | account | account-1 |
test_user | account_admin | MONITOR ANY USAGE | account | account-1 |
test_user | account_admin | MANAGE GRANTS | account | account-1 |
test_user | account_admin | USAGE ANY ENGINE | account | account-1 |
test_user | account_admin | MODIFY ANY USER | account | account-1 |
test_user | account_admin | METER USAGE | account | account-1 |
test_user | account_admin | CREATE SCHEMA | database | UltraFast |
test_user | account_admin | CREATE USER | account | account-1 |
test_user | account_admin | CREATE DATABASE | account | account-1 |
test_user | account_admin | CREATE ROLE | account | account-1 |
test_user | account_admin | CREATE ENGINE | account | account-1 |
test_user
has account-level privileges, such as permission to create engines, roles, and databases, as well as permission to modify users and engines.
Validating privileges at the database level
When a specific database is selected, the query retrieves privileges scoped to that database. Example The following code example retrieves the applicable roles and associated privileges, object types, and object names fortest_user
, who holds an account_admin
role from the information schema.
Grantee | role_name | privilege_type | object_type | object_name |
---|---|---|---|---|
test_user | account_admin | SELECT ANY | schema | public |
test_user | account_admin | DELETE ANY | schema | public |
test_user | account_admin | VACUUM ANY | schema | public |
test_user | account_admin | INSERT ANY | schema | public |
test_user | account_admin | MODIFY | schema | public |
test_user | account_admin | CREATE | schema | public |
test_user | account_admin | USAGE | schema | public |
test_user | account_admin | MODIFY ANY | schema | public |
test_user | account_admin | TRUNCATE ANY | schema | public |
test_user
has database-level privileges, such as SELECT
, INSERT
, DELETE
, and schema-level MODIFY
permissions.