pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedExtract table columns in tabular form
3+ messages / 3 participants
[nested] [flat]
* Extract table columns in tabular form
@ 2005-11-05 16:47 frank church <pgsql@adontendev.net>
0 siblings, 2 replies; 3+ messages in thread
From: frank church @ 2005-11-05 16:47 UTC (permalink / raw)
To: pgsql-sql
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.
R Church
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Extract table columns in tabular form
@ 2005-11-05 18:00 A. Kretschmer <andreas.kretschmer@schollglas.com>
parent: frank church <pgsql@adontendev.net>
1 sibling, 0 replies; 3+ messages in thread
From: A. Kretschmer @ 2005-11-05 18:00 UTC (permalink / raw)
To: pgsql-sql
am 05.11.2005, um 16:47:56 +0000 mailte frank church folgendes:
>
> 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.
Start psql with -E and call \d* - commands to see both the hidden SQL
and the description.
Example:
comment on table foo is 'this is a comment';
\dd foo
[many lines of output the SQL and the comment]
Use '\h?' to see all psql-commands.
HTH, Andreas
--
Andreas Kretschmer (Kontakt: siehe Header)
Heynitz: 035242/47212, D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
=== Schollglas Unternehmensgruppe ===
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Extract table columns in tabular form
@ 2005-11-05 18:14 Christopher Browne <cbbrowne@acm.org>
parent: frank church <pgsql@adontendev.net>
1 sibling, 0 replies; 3+ messages in thread
From: Christopher Browne @ 2005-11-05 18:14 UTC (permalink / raw)
To: pgsql-sql
> 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
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2005-11-05 18:14 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-11-05 16:47 Extract table columns in tabular form frank church <pgsql@adontendev.net>
2005-11-05 18:00 ` A. Kretschmer <andreas.kretschmer@schollglas.com>
2005-11-05 18:14 ` Christopher Browne <cbbrowne@acm.org>
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