- 论坛徽章:
- 0
|
查看表的访问权限查可以用:
登录到数据库:
#\dp 表名
#\z 表名
例子:
# \z t_host
Access privileges for database "db_3as"
Schema | Table | Access privileges
--------+--------+-------------------------------------
public | t_host | {=,administrator=arwdRxt,guangxi=r}
(1 row)
这是已知表名查看其授权情况,但如何查看一个用户的访问权限呢?
相关信息从pg_class表中可以取得
例子:
# select relname,relacl from pg_class where relname='t_host';
relname | relacl
---------+-------------------------------------
t_host | {=,administrator=arwdRxt,guangxi=r}
(1 row)
这个方法和\z 命令获取的信息差不多,可以限定表名,但限定用户操作有问题!
relacl类型为 aclitem[] ;应该是一个数组类型;可以用relacl[1], relacl[2] ...等来操作,但是在匹配用户时遇到了困难,用like操作不了,转换类型也出错:cast (relacl[1] as text) 或 cast (relacl as text)均不成功。
有没有其他思路呢?希望大家提点意见! |
|