数据仓库服务 GAUSSDB(DWS)-PG_DEFAULT_ACL:应用示例

时间:2024-12-09 15:13:10

应用示例

查看新建用户role1的初始权限:

1
2
3
4
select * from PG_DEFAULT_ACL;
 defaclrole | defaclnamespace | defaclobjtype |    defaclacl
------------+-----------------+---------------+-----------------
      16820 |           16822 | r             | {role1=r/user1}

也可使用如下语句进行转换后更直观的查看:

1
SELECT pg_catalog.pg_get_userbyid(d.defaclrole) AS "Granter",  n.nspname AS "Schema",  CASE d.defaclobjtype WHEN 'r' THEN 'table' WHEN 'S' THEN 'sequence' WHEN 'f' THEN 'function' WHEN 'T' THEN 'type' END AS "Type",  pg_catalog.array_to_string(d.defaclacl, E', ') AS "Access privileges" FROM pg_catalog.pg_default_acl d LEFT JOIN pg_catalog.pg_namespace n ON n.oid = d.defaclnamespace ORDER BY 1, 2, 3;

输出结果如下,表示通过用户user1授予用户role1对模式“user1”有读的权限。

1
2
3
4
 Granter | Schema | Type  | Access privileges
---------+--------+-------+-------------------
 user1   | user1  | table | role1=r/user1
(1 row)
support.huaweicloud.com/devg-910-dws/dws_04_0584.html