Re: Get the tables names?
От | Tom Lane |
---|---|
Тема | Re: Get the tables names? |
Дата | |
Msg-id | 5021.995662920@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: Get the tables names? (Dado Feigenblatt <dado@wildbrain.com>) |
Список | 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 по дате отправления: