Re: newbie question... how do I get table structure? - Mailing list pgsql-general

From Franco Bruno Borghesi
Subject Re: newbie question... how do I get table structure?
Date
Msg-id 1076079645.68312.9.camel@taz.oficina.oficina
Whole thread Raw
In response to Re: newbie question... how do I get table structure?  (Aaron Bratcher <aaronbratcher@abdatatools.com>)
Responses Re: newbie question... how do I get table structure?  (Richard Huxton <dev@archonet.com>)
Re: newbie question... how do I get table structure?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
this should work (don't forget to replace <TABLE NAME>!!!):

SELECT
A.attname,
pg_catalog.format_type(a.atttypid, a.atttypmod) AS typeName
FROM
pg_class C,
pg_attribute A,
pg_type T
WHERE
C.relname ILIKE '<TABLE NAME>' AND
(C.oid=A.attrelid) AND
(T.oid=A.atttypid) AND
(A.attnum>0) AND
(NOT A.attisdropped)
ORDER BY
A.attnum;

Does anyone know if the ansi sql standard defines any way to do this?
I've seen the DESCRIBE TABLE/INDEX/... or SHOW TABLE/INDEX/... commands in other databases, but I don't really know if they are extensions or not.

On Fri, 2004-02-06 at 11:10, Aaron Bratcher wrote:
Is there no way I can do it with a standard select command in a 
different client? I don't need the indexes, just the column 
names/types.
--
Aaron Bratcher
ab DataTools
http://www.abDataTools.com


On Feb 6, 2004, at 8:12 AM, Harald Fuchs wrote:

> In article <4022FB80.6090205@commandprompt.com>,
> "Joshua D. Drake" <jd@commandprompt.com> writes:
>
>> Aaron Bratcher wrote:
>>> What command can I use to get the structure of a given table?
>>>
>
>
>> If psql is client
>
>> \d tablename
>
> Without psql you can use
>
>   pg_dump -s DBNAME -t TBLNAME
>
> from your shell prompt.


---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings
Attachment

pgsql-general by date:

Previous
From: "Henrik Steffen"
Date:
Subject: Re: newbie question... how do I get table structure?
Next
From: "Wei Wang"
Date:
Subject: Run 2 versions of Postgresql on one machine?