postgres=# du
SELECT r.rolname, r.rolsuper, r.rolinherit,
r.rolcreaterole, r.rolcreatedb, r.rolcanlogin,
r.rolconnlimit, r.rolvaliduntil,
ARRAY(SELECT b.rolname
FROM pg_catalog.pg_auth_members m
JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid)
WHERE m.member = r.oid) as memberof
, r.rolreplication
, r.rolbypassrls
FROM pg_catalog.pg_roles r
WHERE r.rolname !~ '^pg_'
ORDER BY 1;
SELECT usename AS role_name,
CASE
WHEN usesuper AND usecreatedb THEN
cast('superuser, create database' AS pg_catalog.text)
WHEN usesuper THEN
cast('superuser' AS pg_catalog.text)
WHEN usecreatedb THEN
cast('create database' AS pg_catalog.text)
ELSE
cast('' AS pg_catalog.text)
END AS role_attributes
FROM pg_catalog.pg_user
ORDER BY role_name DESC;