Re: describe table query?

Поиск
Список
Период
Сортировка
Искать
От
Alex Krohn
Тема
Re: describe table query?
Дата
Msg-id
20020909180030.DC3B.ALEX@gossamer-threads.com
Ответ на
describe table query? (Andrew Bulmer)
Список
Дерево обсуждения
describe table query? Andrew Bulmer <toastafari@yahoo.com>
Re: describe table query? Alex Krohn <alex@gossamer-threads.com>
Re: describe table query? snpe <snpe@snpe.co.yu>
Re: describe table query? Dan Ostrowski <dan@triad-dev.com>
Re: describe table query? snpe <snpe@snpe.co.yu>
Re: describe table query? "scott.marlowe" <scott.marlowe@ihs.com>
Re: describe table query? snpe <snpe@snpe.co.yu>
Re: describe table query? "scott.marlowe" <scott.marlowe@ihs.com>
Re: describe table query? snpe <snpe@snpe.co.yu>
Re: describe table query? Andrew Bulmer <toastafari@yahoo.com>
Re: describe table query? Darren Ferguson <darren@crystalballinc.com>
Hi Andrew,

> I'm trying to write an Access clone in java that will
> use PostGres as a backend. Problem is, I need to be
> able to list all the fields (and data types) in a
> table. I know about "\d" but that only seems to work
> on the command line client (doesn't work if I pass it
> in as a query). I know in mysql DESCRIBE  will
> do it... is there an equivalent in postgres? I tried
> google but all I could find were references to the \d command.

We use:

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 = 'YOURTABLE'
    and a.attnum > 0 
    and a.attrelid = c.oid 
    and a.atttypid = t.oid 
ORDER BY attnum 

But I'd be interested to hear if there is a better way. =)

Hope that helps,

Alex

--
Alex Krohn 
В списке pgsql-general по дате отправления
От: Dan Ostrowski
Дата:
Сообщение: Re: describe table query?
От: Bruce Momjian
Дата:
FAQ