Question about schema
Question about schema
От:
dbms dbms <dbmss@yahoo.com>
Дата:
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
Re: [SQL] Question about schema
От:
"G. Anthony Reina" <reina@nsi.edu>
Дата:
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
Re: Question about schema
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
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 = '