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
paon 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@earthtribe.net]
Sent: Wednesday, January 24, 2001 12:01 PM
To: pgsql-sql@postgresql.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