SHOW GRANTS

查询当前用户、指定角色或指定用户所拥有的权限,帮助了解权限设置情况,确保数据访问的安全性。

查看对象上的权限语法

查看某个具体对象(表、Schema、Workspace、VCluster 等)上授予了哪些权限。

SHOW GRANTS ON TABLE [schema.]table_name; SHOW GRANTS ON SCHEMA schema_name; SHOW GRANTS ON WORKSPACE workspace_name; SHOW GRANTS ON VCLUSTER vcluster_name; SHOW GRANTS ON VOLUME [schema.]volume_name; SHOW GRANTS ON ROLE role_name;

使用示例

-- 查看表上的所有授权 SHOW GRANTS ON TABLE public.orders; -- 查看 Schema 上的所有授权 SHOW GRANTS ON SCHEMA public; -- 查看 VCluster 上的所有授权 SHOW GRANTS ON VCLUSTER default; -- 查看 Workspace 上的所有授权 SHOW GRANTS ON WORKSPACE my_workspace;

返回列与

SHOW GRANTS TO ROLE
SHOW GRANTS TO ROLE
相同,见上方返回列说明。


Workspace 角色查看权限语法

-- 查看当前用户的权限 SHOW GRANTS; -- 查询指定角色的权限 SHOW GRANTS TO ROLE role_name; -- 查询指定用户的权限 SHOW GRANTS TO USER user_name;

参数说明

参数必填说明
role_name
role_name
是(查询角色时)需要查询权限的角色名称,该角色必须存在于当前工作空间中
user_name
user_name
是(查询用户时)需要查询权限的用户名称,该用户必须存在于当前工作空间中

返回列说明

列名说明
granted_type
granted_type
授权类型:
ROLE
ROLE
(角色授权)或
PRIVILEGE
PRIVILEGE
(对象权限授权)
privilege
privilege
权限名称,如
SELECT TABLE
SELECT TABLE
workspace_dev
workspace_dev
conditions
conditions
附加条件(通常为空)
granted_on
granted_on
授权对象类型,如
ROLE
ROLE
TABLE
TABLE
SCHEMA
SCHEMA
object_name
object_name
授权对象的完整名称(含工作空间前缀)
granted_to
granted_to
被授权的主体类型,如
ROLE
ROLE
USER
USER
grantee_name
grantee_name
被授权方的完整名称(含工作空间前缀)
grantor_name
grantor_name
执行授权操作的用户名称
grant_option
grant_option
是否具有转授权限:
true
true
表示可将该权限再授予其他用户
granted_time
granted_time
授权时间

使用示例

  1. 查看当前用户的权限:

    SHOW GRANTS;

  2. 查询角色

    test_developer_role
    test_developer_role
    的权限:

    SHOW GRANTS TO ROLE test_developer_role;

    返回示例:

granted_typeprivilegegranted_onobject_namegranted_tograntee_namegrantor_namegrant_optiongranted_time
PRIVILEGECREATE TABLESCHEMAquick_start.semantic_model_testROLEquick_start.test_developer_rolequick_start.qiliangfalse2025-03-27 20:43:39.419
  1. 查询用户

    tester
    tester
    的权限:

    SHOW GRANTS TO USER tester;

    返回示例:

granted_typeprivilegegranted_onobject_namegranted_tograntee_namegrantor_namegrant_optiongranted_time
ROLEworkspace_devROLEquick_start.workspace_devUSERquick_start.testerquick_start.qiliangfalse2025-03-27 20:43:39.419

注意事项

  • 执行此命令需要具备
    workspace_admin
    workspace_admin
    security_admin
    security_admin
    角色,或者查询的是当前登录用户自身的权限。
  • 返回结果包含直接授予的权限,以及通过角色间接获得的权限(
    granted_type
    granted_type
    ROLE
    ROLE
    的行表示通过角色获得的权限)。
  • 用户名和角色名区分大小写,请确保输入正确。

Instance 角色查看权限语法

-- 查询指定 Instance Role 的权限 SHOW GRANTS TO INSTANCE ROLE role_name;

参数说明

参数必填说明
role_name
role_name
需要查询权限的 Instance Role 名称

Instance 使用示例

-- 查看某个 Instance Role 的权限 SHOW GRANTS TO INSTANCE ROLE instance_datamap_user;

联系我们
预约咨询
微信咨询
电话咨询