2016-02-24 36 views
0

我正在使用postgresql版本9.4.5。我將用戶添加到超級用戶角色(Master),如下:如何找出添加到postgresql中的角色的用戶?

grant testuser1 to master; 
grant testuser2 to master; 

現在如何找出用戶的名單加入到這個角色的「主人」。是有任何具體的系統表/視圖查詢這個?我需要在where子句中傳遞角色名稱'maser'。

很多謝謝

+0

也許這會給你和主意,開始http://dba.stackexchange.com/questions/56096/how-to-get-all-roles-that-a-user包括繼承-角色-is-A-構件的- –

回答

0

我試過這個,belwo查詢正確顯示結果。有人可以確認這個查詢是否正確?

testdb= #grant testuser1 to master; 
GRANT ROLE 

testdb= #grant testuser2 to master; 
GRANT ROLE 

testdb= #grant testuser3 to master; 
GRANT ROLE 

SELECT rolname FROM pg_roles WHERE 
    pg_has_role('master', oid, 'member') 
and rolname not in ('master') 

    rolname 
---------------- 
testuser1 
testuser2 
testuser3 
(3 rows) 

非常感謝,

相關問題