From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Dado Feigenblatt <dado(at)wildbrain(dot)com> |
Cc: | Magnus Landahl <magnus(dot)landahl(at)datessa(dot)se>, pgsql <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Get the tables names? |
Date: | 2001-07-20 21:02:00 |
Message-ID: | 5021.995662920@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Dado Feigenblatt <dado(at)wildbrain(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Magnus Landahl | 2001-07-20 21:14:40 | Re: Get the tables names? |
Previous Message | Chris Ruprecht | 2001-07-20 20:59:52 | Re: TODO List |