I have an audit requirement to query all roles granted to users; listed by user. For example:
Username Roles
user1 role1_rw, role2_ro, rol3_rw
user2 role2_rw
I cannnot use psql meta-commands as this result set will be merged with some other queries to do analysis of the grants. The roles have been created to manage ro/rw access to various application schemas. In oracle, this is quite straight forward; I dont see a single view to return this in Postgres. The querying user is a superuser.
Does anyone have a query to return this? Postgres 9.4 on ubuntu
psql
meta-commands are backed by ordinary SQL queries. Just do a\set ECHO_HIDDEN on
before running a\du
, for example. It will show you the query being used to obtain the output.