Re: Get the tables names? - Mailing list pgsql-sql

From Tom Lane
Subject Re: Get the tables names?
Date
Msg-id 5021.995662920@sss.pgh.pa.us
Whole thread Raw
In response to Re: Get the tables names?  (Dado Feigenblatt <dado@wildbrain.com>)
List pgsql-sql
Dado Feigenblatt <dado@wildbrain.com> writes:
> The only thing is that this includes system tables.
> So if you want to strip those you need to
>     SELECT relname , relowner FROM pg_class WHERE relkind = 'r' and 
> relowner != 26;

> Is user postgres always 26?

It certainly is not.  Even if it was, the above would exclude ordinary
tables that had been created by the dbadmin/superuser.

The convention that's really used is that system tables have names
starting with 'pg_' --- the code will actually not let you create a
table with such a name, so that the convention can be relied on.
So the correct way to exclude system tables is

SELECT * FROM pg_class WHERE relkind = 'r' and relname not like 'pg_%';

If you try "\d" in psql after starting it with -E option, you will
discover that this is indeed what psql does ...
        regards, tom lane


pgsql-sql by date:

Previous
From: Jeff Eckermann
Date:
Subject: RE: PLpgSQL
Next
From: Dado Feigenblatt
Date:
Subject: Re: PLpgSQL