pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedQuestion about schema
3+ messages / 3 participants
[nested] [flat]
* Question about schema
@ 1998-11-25 01:20 dbms dbms <dbmss@yahoo.com>
0 siblings, 1 reply; 3+ messages in thread
From: dbms dbms @ 1998-11-25 01:20 UTC (permalink / raw)
To: pgsql-sql
Hi all,
Can I use SQL to get info about a table
which can be gotten by doing a
\d [table name]
under psql?
Rdbms
_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: [SQL] Question about schema
@ 1998-11-25 01:49 G. Anthony Reina <reina@nsi.edu>
parent: dbms dbms <dbmss@yahoo.com>
0 siblings, 0 replies; 3+ messages in thread
From: G. Anthony Reina @ 1998-11-25 01:49 UTC (permalink / raw)
To: dbms dbms <dbmss@yahoo.com>; pgsql-sql
If you just want to know what your table looks like, try:
select * from pg_class;
To just get the class names, try select relname from pg_class;
I'm pretty sure that you can execute this from psql c-commands.
-Tony
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Question about schema
@ 1998-11-25 15:55 Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 3+ messages in thread
From: Tom Lane @ 1998-11-25 15:55 UTC (permalink / raw)
To: dbmss@yahoo.com; +Cc: pgsql-sql@hub.org
dbmss@yahoo.com writes:
> Can I use SQL to get info about a table
> which can be gotten by doing a
> \d [table name]
> under psql?
psql uses plain old SQL queries to extract the info it presents with \d;
it's not doing anything you couldn't do too. Read the source code for
psql (src/bin/psql/psql.c) to see what queries are used to produce the
various sorts of \d reports. For example, the particular case of
"\d table" is handled in the routine named tableDesc, and from looking
at that you can see that it constructs a primary query like this:
SELECT a.attnum, a.attname, t.typname, a.attlen,
a.atttypmod, a.attnotnull, a.atthasdef
FROM pg_class c, pg_attribute a, pg_type t
WHERE c.relname = '<table name here>'
and a.attnum > 0
and a.attrelid = c.oid
and a.atttypid = t.oid
ORDER BY attnum
Looks like there are additional queries made to get the values of field
defaults and so forth.
All this stuff is kept in the system tables, and you can query those
tables with ordinary queries.
regards, tom lane
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~1998-11-25 15:55 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1998-11-25 01:20 Question about schema dbms dbms <dbmss@yahoo.com>
1998-11-25 01:49 ` G. Anthony Reina <reina@nsi.edu>
1998-11-25 15:55 Re: Question about schema Tom Lane <tgl@sss.pgh.pa.us>
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