Find if a user belongs to any groups

posted Nov 1, 2014, 7:51 AM by Sachchida Ojha
sachi=# select usesysid, usename, COALESCE(groname,'default') from pg_user u left join pg_group g on ','||array_to_string(grolist,',')||','   like '%,'||cast(usesysid as varchar(10))||',%' where usename='sachi' order by 2,1;
 usesysid | usename | coalesce 
----------+---------+----------
    16994 | sachi   | admin
(1 row)

sachi=# 

Comments