From: Christopher Browne <cbbrowne@acm.org>
To: pgsql-sql@postgresql.org
Subject: Re: Extract table columns in tabular form
Date: Sat, 05 Nov 2005 13:14:12 -0500
Message-ID: <m3u0er6jyj.fsf@mobile.int.cbbrowne.com> (raw)
References: <1131209276.436ce23cba2d2@webmail.adontendev.net>
> How do you extract postgresql column names, types and comments in tabular form,
> using an SQL command?. I know they are stored in one of the system tables, but
> I don't know which.
- Table names are in pg_class
- Column names are in pg_attribute, associated to pg_class via
"where pg_attribute.attrelid = pg_class.oid"
- Comments are in pg_description... There seem to be links to both
pg_class and pg_attribute
- Type info is in pg_type, associated to pg_attribute via "atttypid"
There are attributes that you normally don't see, and "dropped"
attributes still exist in pg_attribute, so things are a tad more
complex than what I have said, but the above 4 tables should provide
you all you need...
--
select 'cbbrowne' || '@' || 'acm.org';
http://linuxdatabases.info/info/slony.html
Never criticize anybody until you have walked a mile in their shoes,
because by that time you will be a mile away and have their shoes.
-- email sig, Brian Servis
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: cbbrowne@acm.org
Subject: Re: Extract table columns in tabular form
In-Reply-To: <m3u0er6jyj.fsf@mobile.int.cbbrowne.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