Re: newbie question... how do I get table structure?

From: Franco Bruno Borghesi <franco(at)akyasociados(dot)com(dot)ar>
To: Aaron Bratcher <aaronbratcher(at)abdatatools(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: newbie question... how do I get table structure?
Date: 2004-02-06 15:00:46
Message-ID: 1076079645.68312.9.camel@taz.oficina.oficina
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(dot)6090205(at)commandprompt(dot)com>,
> > "Joshua D. Drake" <jd(at)commandprompt(dot)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
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Henrik Steffen 2004-02-06 15:01:06 Re: newbie question... how do I get table structure?
Previous Message Mark Gibson 2004-02-06 14:42:51 Re: newbie question... how do I get table structure?