Re: describe table query?
От | Alex Krohn |
---|---|
Тема | Re: describe table query? |
Дата | |
Msg-id | 20020909180030.DC3B.ALEX@gossamer-threads.com обсуждение исходный текст |
Ответ на | describe table query? (Andrew Bulmer <toastafari@yahoo.com>) |
Список | pgsql-general |
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 <table> 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 <alex@gossamer-threads.com>
В списке pgsql-general по дате отправления: