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