查看: 1365|回复: 1

PostgreSQL的权限查询

 关闭 [复制链接]

签到天数: 2623 天

连续签到: 2 天

[LV.Master]至尊海神IIIIII

发表于 2010-10-14 19:24 |广东| 显示全部楼层 |阅读模式
PostgreSQL的权限查询  
查看哪些用户对表t1有哪些权限:
part00=# \z t1
                           Access privileges
Schema | Name | Type  |  Access privileges  | Column access privileges
--------+------+-------+---------------------+--------------------------
public | t1   | table | osdba=arwdDxt/osdba+|
        |      |       | scott=D/osdba       |


part00=# \dp t1
                           Access privileges
Schema | Name | Type  |  Access privileges  | Column access privileges
--------+------+-------+---------------------+--------------------------
public | t1   | table | osdba=arwdDxt/osdba+|
        |      |       | scott=D/osdba       |
(1 row)
可以看出有两个用户osdba和scott,osdba用arwdDxt权限,scott用户有D权限。
字母代表的权限的意思如下:
a: insert
r: select
w: update
d: delete
x: references
t: trigger
D: truncate


也可以查询系统视图pg_class
part00=# select relname,relacl from pg_class where relname='t1';
relname |               relacl               
---------+-------------------------------------
t1      | {osdba=arwdDxt/osdba,scott=D/osdba}
(1 row)


如果想查询用户scott有哪些权限,可以查询系统表information_schema.role_table_grants:
part00=# select * from INFORMATION_SCHEMA.role_table_grants where grantee='scott';
grantor | grantee | table_catalog | table_schema | table_name | privilege_type | is_grantable | with_hierarchy
---------+---------+---------------+--------------+------------+----------------+--------------+----------------
osdba   | scott   | part00        | public       | t4         | SELECT         | NO           | NO
osdba   | scott   | part00        | public       | t1         | TRUNCATE       | NO           | NO






PCOS系统下载站:http://zhuangji.wang

签到天数: 413 天

连续签到: 0 天

[LV.9]尊贵海王II

发表于 2011-3-12 14:37 |湖北| 显示全部楼层
恩 是这样  应该  我没有测试
PCOS系统下载站:http://zhuangji.wang
回复 支持 反对

使用道具 举报

本版积分规则