From: | Michael Davis <mdavis(at)sevainc(dot)com> |
---|---|
To: | "'Mike D'Agosta'" <mdagosta(at)earthtribe(dot)net>, "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org> |
Subject: | RE: Is there anything like DESCRIBE? |
Date: | 2001-01-25 20:57:08 |
Message-ID: | 01C086D6.B80EB9B0.mdavis@sevainc.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
This works for me:
SELECT DISTINCT c.relname as table_name, a.attname as column_name, t.typname, pa.adsrc as default
FROM (pg_attribute a
join pg_class c on a.attrelid = c.oid
join pg_type t on a.atttypid = t.oid)
left join pg_attrdef pa on c.oid = pa.adrelid AND a.attnum = pa.adnum
where exists (select * from pg_tables where tablename = c.relname and substr(tablename,1,2) <> 'pg')
order by c.relname, a.attname;
-----Original Message-----
From: Mike D'Agosta [SMTP:mdagosta(at)earthtribe(dot)net]
Sent: Wednesday, January 24, 2001 12:01 PM
To: pgsql-sql(at)postgresql(dot)org
Subject: Is there anything like DESCRIBE?
Hi,
I have a number of empty tables and I want to get the column names and
data types with an SQL statement. I want to do this procedurally, not
interactively (so I can't use \d <tablename> in psql). Postgres doesn't
support DESCRIBE... is there any other way to do this?
Thanks!
Mike
From | Date | Subject | |
---|---|---|---|
Next Message | Najm Hashmi | 2001-01-25 20:59:23 | Re: How to change the ownership of the table? |
Previous Message | Mike D'Agosta | 2001-01-25 20:56:17 | Re: Is there anything like DESCRIBE? |