Re: how to list privileges on the database object itself via SQL?

From: richard coleman <rcoleman(dot)ascentgl(at)gmail(dot)com>
To: MichaelDBA <MichaelDBA(at)sqlexec(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-admin(at)lists(dot)postgresql(dot)org
Subject: Re: how to list privileges on the database object itself via SQL?
Date: 2023-04-26 17:57:22
Message-ID: CAGA3vBuRQgz0RK-OC0f0o+n-n24oWrUNhCU_yx_xJrsEyKj0zw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Michael,

Thanks, but that lists privs in tables. There are lots and lots of ways to
get table privs.

What I am looking for is a simple way to get the privs on the database
object itself.

rik.

On Wed, Apr 26, 2023 at 1:35 PM MichaelDBA <MichaelDBA(at)sqlexec(dot)com> wrote:

> Here's a teaser:
>
> select c.relnamespace::regnamespace as schema, c.relname as tablename ,
> pg_catalog.array_to_string(c.relacl, E'\n') AS privileges,
> CASE WHEN c.relkind = 'r' THEN 'TABLE' WHEN c.relkind = 'S' THEN
> 'SEQUENCE' WHEN c.relkind = 'v' THEN 'VIEW' WHEN c.relkind = 'm' THEN
> 'MATVIEW' WHEN c.relkind = 'p' THEN 'PARTITIONED TABLE' END as object_type
> FROM pg_class c WHERE c.relnamespace::regnamespace::text not in
> ('pg_catalog','information_schema') AND c.relkind IN ('r','v','m','S','p')
> ORDER BY 1,2;
>
> Regards,
> Michael Vitale
>
> richard coleman wrote on 4/26/2023 1:20 PM:
>
> Tom,
>
> Thanks, but no. I am looking for the SQL statement.
>
> I very rarely venture into psql, unless it's to run an SQL code block from
> the terminal.
> Is there an SQL way to do this?
>
> Thanks again,
> rik.
>
> On Wed, Apr 26, 2023 at 12:40 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
>> richard coleman <rcoleman(dot)ascentgl(at)gmail(dot)com> writes:
>> > This might sound like a silly question, but how would I list the
>> privileges
>> > the various roles have on the database objects themselves?
>>
>> Perhaps you are looking for psql's \l command? It's a bit
>> nonstandardly named (one would expect \d something)
>>
>> regards, tom lane
>>
>
>
> Regards,
>
> Michael Vitale
>
> Michaeldba(at)sqlexec(dot)com <michaelvitale(at)sqlexec(dot)com>
>
> 703-600-9343
>
>
>
>

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message richard coleman 2023-04-26 18:00:19 Re: how to list privileges on the database object itself via SQL?
Previous Message Holger Jakobs 2023-04-26 17:55:43 Re: how to list privileges on the database object itself via SQL?