From: | "Ross J(dot) Reedstrom" <reedstrm(at)rice(dot)edu> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: [SQL] how to retrieve... |
Date: | 1999-04-09 23:37:53 |
Message-ID: | 370E8F51.EE94D7BC@rice.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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(at)rice(dot)edu>
NSBRI Research Scientist/Programmer
Computer and Information Technology Institute
Rice University, 6100 S. Main St., Houston, TX 77005
From | Date | Subject | |
---|---|---|---|
Next Message | Will Benton | 1999-04-11 23:30:58 | aggregate functions and varchar type |
Previous Message | Jens Glaser | 1999-04-09 17:41:53 | Nested subqueries in the target list |