From: Michael Davis <mdavis@sevainc.com>
To: 'Mike D'Agosta' <mdagosta@earthtribe.net>
To: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: RE: Is there anything like DESCRIBE?
Date: Thu, 25 Jan 2001 13:57:08 -0700
Message-ID: <01C086D6.B80EB9B0.mdavis@sevainc.com> (raw)
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@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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: mdavis@sevainc.com, mdagosta@earthtribe.net
Subject: Re: Is there anything like DESCRIBE?
In-Reply-To: <01C086D6.B80EB9B0.mdavis@sevainc.com>
References: <01C086D6.B80EB9B0.mdavis@sevainc.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox