AWS Redshift list of schema and tables along with group names

Viewed 562

I am looking for SQL code which can list Schema names and Table names along with Group names. This is to find that which Schema name or Table name falls in which group. With below code I can find which user is in which group easily but not Schema names and Tables names. Is there any way to join pg_namespace with pg_group.

SELECT usename, groname 
FROM pg_user, pg_group
WHERE pg_user.usesysid = ANY(pg_group.grolist)
AND pg_group.groname in (SELECT DISTINCT pg_group.groname from pg_group);
0 Answers
Related