pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: pinker <pinker@onet.eu>
To: pgsql-general@postgresql.org
Subject: Re: List user who have access to schema
Date: Fri, 3 Aug 2018 07:26:25 -0700 (MST)
Message-ID: <1533306385561-0.post@n3.nabble.com> (raw)
In-Reply-To: <CAJP7dtAWGcS9qHFWnFZhyunheGHVnWU-3O=GetD9DNdpSCHqZQ@mail.gmail.com>
References: <CAJP7dtAWGcS9qHFWnFZhyunheGHVnWU-3O=GetD9DNdpSCHqZQ@mail.gmail.com>

I think this one will give you report you need:

select schema_name, 
roleid::regrole, 
string_agg(member::regrole::text,',' order by member::regrole::text) users
from information_schema.schemata s, pg_user u
JOIN pg_auth_members a ON u.usename::text=a.roleid::regrole::text
WHERE s.schema_name not like 'pg_%' AND has_schema_privilege(usename,
s.schema_name, 'usage')
GROUP BY s.schema_name, roleid::regrole, u.usename
order by 1;



--
Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html




view thread (6+ messages)

Message-ID: <1533306385561-0.post@n3.nabble.com>
Permalink:  ../1533306385561-0.post@n3.nabble.com/
Also on:    postgresql.org/message-id/1533306385561-0.post@n3.nabble.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: pinker@onet.eu
  Subject: Re: List user who have access to schema
  In-Reply-To: <1533306385561-0.post@n3.nabble.com>
  References: <CAJP7dtAWGcS9qHFWnFZhyunheGHVnWU-3O=GetD9DNdpSCHqZQ@mail.gmail.com> <1533306385561-0.post@n3.nabble.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox