Solved: Getting the field names for a given table - Mailing list pgsql-general

From dcrespo
Subject Solved: Getting the field names for a given table
Date
Msg-id 1186614384.209826.97100@d30g2000prg.googlegroups.com
Whole thread Raw
List 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 by date:

Previous
From: "Anderson Alves de Albuquerque "
Date:
Subject: Permission ALTER PASSWORD
Next
From: "John Coulthard"
Date:
Subject: Unable to connect to PostgreSQL server via PHP