Solved: Getting the field names for a given table

Поиск
Список
Период
Сортировка
От dcrespo
Тема Solved: Getting the field names for a given table
Дата
Msg-id 1186614384.209826.97100@d30g2000prg.googlegroups.com
обсуждение исходный текст
Список pgsql-general
For those who need to know the fields that a certain table has in a
postgresql database, here is the SQL statement:

SELECT DISTINCT attname, relname FROM pg_attribute pa, pg_class pc,
pg_tables pt WHERE pa.attrelid=pc.oid AND pc.relname=pt.tablename AND
pt.schemaname='public' AND attstattarget=-1 AND relname IN (SELECT
tablename FROM pg_tables WHERE schemaname='public') ORDER BY relname;

Notice that you can replace ***relname IN (SELECT tablename FROM
pg_tables WHERE schemaname='public')*** with
***relname='your_desired_tablename'*** and will do the work only for
an specific table. For the newbies: you can specify the schemaname if
needed.

Daniel


В списке pgsql-general по дате отправления:

Предыдущее
От: "Anderson Alves de Albuquerque "
Дата:
Сообщение: Permission ALTER PASSWORD
Следующее
От: "John Coulthard"
Дата:
Сообщение: Unable to connect to PostgreSQL server via PHP