How do I list every privilege granted to each role in PostgreSQL?
I have created some roles, a function, and granted various privileges across a schema. Now I would like an overview: for each role, everything it has been granted.
The built-in role listing shows attributes and memberships but nothing about object privileges. I have not found a single view that pulls it all together.
Is there a straightforward way to get this, or does it genuinely require assembling it from several places?
@postgres_polat · last wk.
It genuinely requires assembling it, and the reason is structural: privileges are stored on the objects, not on the roles.
Each object carries an access control list recording who may do what to it. There is no central table of grants to walk, so a per-role view has to be built by scanning every object type and filtering.
Which means the practical answer is to query the information schema views, one per object class:
Union those together with a role column and you have your overview.
Reply
Report