SHOW GRANTS TO USER

Description

Queries all permissions granted to a specified user in the current workspace, including directly granted object privileges and permissions inherited through roles.

Syntax

SHOW GRANTS TO USER user_name;

Parameter Description

ParameterRequiredDescription
user_nameYesThe name of the user to query permissions for; the user must already exist in the current workspace

Return Column Description

Column NameDescription
granted_typeGrant type: ROLE (role grant) or PRIVILEGE (object privilege grant)
privilegePermission name, such as SELECT TABLE, workspace_dev, etc.
conditionsAdditional conditions (usually empty)
granted_onType of object the permission is granted on, such as ROLE, TABLE, SCHEMA, etc.
object_nameFull name of the granted object (including workspace prefix)
granted_toType of the grantee; always USER
grantee_nameFull name of the granted user (including workspace prefix)
grantor_nameName of the user who performed the grant operation
grant_optionWhether the permission can be re-granted: true means the permission can be granted to other users
granted_timeTime when the permission was granted

Usage Examples

  1. Query all permissions held by user tester:

    SHOW GRANTS TO USER tester;

    Example output:

granted_typeprivilegegranted_onobject_namegrantee_namegrantor_namegrant_optiongranted_time
ROLEworkspace_devROLEquick_start.workspace_devquick_start.testerquick_start.qiliangfalse2025-03-27 20:43:39.419
  1. Query the permissions of the currently logged-in user:

    SHOW GRANTS TO USER CURRENT_USER();

Notes

  • Executing this command requires the workspace_admin or security_admin role, or the query must be for the currently logged-in user's own permissions.
  • Results include both directly granted permissions and permissions obtained indirectly through roles (rows where granted_type is ROLE indicate permissions obtained through a role).
  • To view the specific permissions contained in a role, use SHOW GRANTS TO ROLE role_name.
  • Usernames are case-sensitive. Ensure correct input.
  • If the user does not exist, the command raises an error rather than returning an empty result set.