假设我有两个 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。
但是当有继承时,我不知道该怎么做。
如何删除角色成员?我的角色名称tester是角色postgres 的成员(我不想要)。如何删除此会员资格?
Role name | Attributes | Member of
-----------+------------------------------------------------+------------
tester | | {postgres}
postgres | Superuser, Create role, Create DB, Replication | {}
Run Code Online (Sandbox Code Playgroud)