Re: psql \dp equivalent or similar query?

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: psql \dp equivalent or similar query?
Date: 2010-07-06 09:32:42
Message-ID: 20100706093242.GD13709@a-kretschmer.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

In response to Davor J. :
> I couldn't find it on the net. I also coudn't find any reference to it in
> the psql source?
>
> Anyone any suggestions?

Start your psql with option -E to display the query behind:

kretschmer(at)tux:~$ psql -E test
psql (8.4.2)
Type "help" for help.

test=# \dp foo
********* QUERY **********
SELECT n.nspname as "Schema",
c.relname as "Name",
CASE c.relkind WHEN 'r' THEN 'table' WHEN 'v' THEN 'view' WHEN 'S' THEN 'sequence' END as "Type",
pg_catalog.array_to_string(c.relacl, E'\n') AS "Access privileges",
pg_catalog.array_to_string(ARRAY(
SELECT attname || E':\n ' || pg_catalog.array_to_string(attacl, E'\n ')
FROM pg_catalog.pg_attribute a
WHERE attrelid = c.oid AND NOT attisdropped AND attacl IS NOT NULL
), E'\n') AS "Column access privileges"
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r', 'v', 'S')
AND c.relname ~ '^(foo)$'
AND n.nspname !~ '^pg_' AND pg_catalog.pg_table_is_visible(c.oid)
ORDER BY 1, 2;
**************************

Access privileges
Schema | Name | Type | Access privileges | Column access privileges
--------+------+----------+-------------------+--------------------------
public | foo | sequence | |
(1 row)

test=#

Regards, Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header)
GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431 2EB0 389D 1DC2 3172 0C99

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sebastian Ritter 2010-07-06 09:33:39 PostgreSQL trigger execution order
Previous Message Davor J. 2010-07-06 09:17:22 psql \dp equivalent or similar query?