select is_role_in_session("<role_name>"); to verify whether this role is active in the current session.
This command is supported from v3.0.
Usage notes
Users can only activate roles that have been assigned to them. You can query the roles of a user using SHOW GRANTS. You can query the active roles of the current user usingSELECT CURRENT_ROLE(). For more information, see current_role.
The activated role affects all authorization checks, including queries against information_schema system views. For example, after executing SET ROLE role1, queries like SELECT * FROM information_schema.tables will only return tables accessible through role1. This ensures that role-based access control is consistently applied across all system catalogs and metadata queries.
Syntax
Parameters
role_name: the role name
Examples
Query all the roles of the current user.db_admin role.
References
- CREATE ROLE: creates a role.
- GRANT: assigns roles to users or other roles.
- ALTER USER: modifies roles.
- SHOW ROLES: show all roles in the system.
- current_role: show roles of the current user.
- is_role_in_session: verifies whether a role (or a nested role) is active in the current session.
- DROP ROLE: drops a role.