Re: Selecting field names? - Mailing list pgsql-general

From Charles Tassell
Subject Re: Selecting field names?
Date
Msg-id 4.2.0.58.20000410002305.009c95d0@mailer.isn.net
Whole thread Raw
In response to Selecting field names?  (Michael Hall <michael@inteltec.com>)
List pgsql-general
Yes, if you start psql with the -E switch (ie, psql -E -h dbserver
database) then do a \d tablename it will show you the SQL query that's used
to display the table definition.  You can then use this to do your
selects.  Here is what I get when I do the above:

QUERY: SELECT a.attnum, a.attname, t.typname, a.attlen, a.atttypmod,
a.attnotnull, a.atthasdef FROM pg_class c, pg_attribute a, pg_type t WHERE
c.relname = 'tablename'    and a.attnum > 0     and a.attrelid =
c.oid     and a.atttypid = t.oid   ORDER BY attnum

QUERY: SELECT viewname, definition FROM pg_views WHERE viewname like
'tablename'


At 12:57 PM 4/9/00, Michael Hall wrote:
>Is there a way to 'select' the names of the fields and the field types
>of a table?
>
>--
>Michael J. Hall, CCA                    Intelligence Technologies Int'l
>michael@inteltec.com                            http://www.inteltec.com
>secure: mikehall@leo.gov


pgsql-general by date:

Previous
From: Titus Brown
Date:
Subject: Minor hack to support LO string searches
Next
From: "Vipin Samtani"
Date:
Subject: [NOVICE] installation question