pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ross J. Reedstrom <reedstrm@rice.edu>
To: pgsql-sql@postgresql.org
Subject: Re: [SQL] how to retrieve...
Date: Fri, 09 Apr 1999 18:37:53 -0500
Message-ID: <370E8F51.EE94D7BC@rice.edu> (raw)
References: <Pine.LNX.4.05.9904091517120.14729-100000@michel.enter.it>

ZioBudda wrote:
> 
> On Wed, 7 Apr 1999, Margarita Barvinok wrote:
> 
> >
> > Try in psql
> > \d <table name>
> > Is this right answer on your question?
> 
> no, I need it via a query...
> I want to recreate the structure of a table if I know the name of the
> table.
> 

This is in the FAQ - but the answer there is 'look at the source and see
how \d tablename
does it with queries' ;-)

The freshly beta'd V 6.5 has a new optin '-E' (Explain?) where it will
show you the queries psql uses to get at the system table stuff. I
learned by poking arounf the source of pgaccess.tcl, which is included
in the distribution. Here's a partial example from one of my tables:

idas_proto=> \d "Teams"

Table    = Teams
+----------------------------------+----------------------------------+-------+
|              Field               |              Type                |
Length|
+----------------------------------+----------------------------------+-------+
| TeamID                           | int4 not null                   
|     4 |
| TeamName                         | text                            
|   var |
| TeamShortName                    | text                            
|   var |
| TeamIDASRep                      | int4                            
|     4 |
| TeamLeader                       | int4                            
|     4 |
| TeamMission                      | text                            
|   var |
| TeamDescription                  | text                            
|   var |
| TeamImage                        | text                            
|   var |
+----------------------------------+----------------------------------+-------+
Index:    Teams_pkey
idas_proto=> select attname from pg_attribute pa, pg_class pc where
pa.attrelid=pc.oid and pc.relname='Teams';
attname        
---------------
cmax           
xmax           
cmin           
xmin           
oid            
ctid           
TeamID         
TeamName       
TeamShortName  
TeamIDASRep    
TeamLeader     
TeamMission    
TeamDescription
TeamImage      
(14 rows)

idas_proto=> 



-- 
Ross J. Reedstrom, Ph.D., <reedstrm@rice.edu> 
NSBRI Research Scientist/Programmer
Computer and Information Technology Institute
Rice University, 6100 S. Main St.,  Houston, TX 77005



view thread (2+ messages)

Message-ID: <370E8F51.EE94D7BC@rice.edu>
Permalink:  ../370E8F51.EE94D7BC@rice.edu/
Also on:    postgresql.org/message-id/370E8F51.EE94D7BC@rice.edu

 · 

reply

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: reedstrm@rice.edu
  Subject: Re: [SQL] how to retrieve...
  In-Reply-To: <370E8F51.EE94D7BC@rice.edu>
  References: <Pine.LNX.4.05.9904091517120.14729-100000@michel.enter.it> <370E8F51.EE94D7BC@rice.edu>

* 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