相关疑难解决方法(0)

如何获取用户所属的所有角色(包括继承的角色)?

假设我有两个 Postgresql 数据库组,“authors”和“editors”,以及两个用户,“maxwell”和“ernest”。

create role authors;

create role editors;

create user maxwell;

create user ernest;

grant authors to editors; --editors can do what authors can do

grant editors to maxwell; --maxwell is an editor

grant authors to ernest; --ernest is an author
Run Code Online (Sandbox Code Playgroud)

我想编写一个高性能函数,它返回 maxwell 所属的角色列表(最好是他们的 oid),如下所示:

create or replace function get_all_roles() returns oid[] ...
Run Code Online (Sandbox Code Playgroud)

它应该返回 maxwell、authors 和 editors(但不是 ernest)的 oid。

但是当有继承时,我不知道该怎么做。

postgresql role access-control users postgresql-9.3

32
推荐指数
4
解决办法
7万
查看次数

postgres 从角色成员中删除用户

如何删除角色成员?我的角色名称tester是角色postgres 的成员(我不想要)。如何删除此会员资格?

 Role name |                   Attributes                   | Member of  
-----------+------------------------------------------------+------------
 tester    |                                                | {postgres}
 postgres  | Superuser, Create role, Create DB, Replication | {}
Run Code Online (Sandbox Code Playgroud)

postgresql

2
推荐指数
1
解决办法
6816
查看次数

标签 统计

postgresql ×2

access-control ×1

postgresql-9.3 ×1

role ×1

users ×1