postgresql with clause

1, view the current version of the database

mydb=# select version();
                                                 version                                                 
---------------------------------------------------------------------------------------------------------
 PostgreSQL 12.0 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39), 64-bit


2, with clauses to view the relationship between the group and the role of

with temp as 

(select  a.rolname,a.rolsuper,m.member from  pg_authid a join pg_auth_members m 

on a.oid=m.roleid)

select temp.rolname,temp.rolsuper,s.rolname as groupname from temp join pg_authid s 

on temp.member = s.oid;



mydb=# with temp as 
mydb-# (select  a.rolname,a.rolsuper,m.member from  pg_authid a join pg_auth_members m 
mydb(# on a.oid=m.roleid)
mydb-# select temp.rolname,temp.rolsuper,s.rolname as groupname from temp join pg_authid s 
mydb-# on temp.member = s.oid;
       rolname        | rolsuper | groupname  
----------------------+----------+------------
 pg_read_all_settings | f        | pg_monitor
 pg_read_all_stats    | f        | pg_monitor
 pg_stat_scan_tables  | f        | pg_monitor



Guess you like

Origin blog.51cto.com/micheng/2462755