pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
how to show table structure?
4+ messages / 4 participants
[nested] [flat]

* how to show table structure?
@ 2004-01-09 23:05  Bing Du <bdu@iastate.edu>
  0 siblings, 2 replies; 4+ messages in thread

From: Bing Du @ 2004-01-09 23:05 UTC (permalink / raw)
  To: pgsql-sql

Greetings,

How can I see the layout of a table in PostgreSQL 7.4?  I've checked
several books and on-line documents, but was not able to figure out how
PostgreSQL does 'describe <table>' like it's done in other databases.

Thanks in advance for any help.

Bing



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: how to show table structure?
@ 2004-01-09 23:10  scott.marlowe <scott.marlowe@ihs.com>
  parent: Bing Du <bdu@iastate.edu>
  1 sibling, 1 reply; 4+ messages in thread

From: scott.marlowe @ 2004-01-09 23:10 UTC (permalink / raw)
  To: Bing Du <bdu@iastate.edu>; +Cc: pgsql-sql

On Fri, 9 Jan 2004, Bing Du wrote:

> Greetings,
> 
> How can I see the layout of a table in PostgreSQL 7.4?  I've checked
> several books and on-line documents, but was not able to figure out how
> PostgreSQL does 'describe <table>' like it's done in other databases.

If in psql, use the \d commands (\? will show you all of them.

However, if you've not got psql to do it, you can look through the 
information_schema for anything like that, like so:

select * from information_schema.tables;

and so on.




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: how to show table structure?
@ 2004-01-09 23:12  Larry Rosenman <ler@lerctr.org>
  parent: Bing Du <bdu@iastate.edu>
  1 sibling, 0 replies; 4+ messages in thread

From: Larry Rosenman @ 2004-01-09 23:12 UTC (permalink / raw)
  To: Bing Du <bdu@iastate.edu>; pgsql-sql



--On Friday, January 09, 2004 17:05:37 -0600 Bing Du <bdu@iastate.edu> 
wrote:

> Greetings,
>
> How can I see the layout of a table in PostgreSQL 7.4?  I've checked
> several books and on-line documents, but was not able to figure out how
> PostgreSQL does 'describe <table>' like it's done in other databases.
\d table

in psql.

LER

>
> Thanks in advance for any help.
>
> Bing
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
>       subscribe-nomail command to majordomo@postgresql.org so that your
>       message can get through to the mailing list cleanly
>



-- 
Larry Rosenman                     http://www.lerctr.org/~ler
Phone: +1 972-414-9812                 E-Mail: ler@lerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: how to show table structure?
@ 2004-01-10 04:03  Kumar <sgnerd@yahoo.com.sg>
  parent: scott.marlowe <scott.marlowe@ihs.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Kumar @ 2004-01-10 04:03 UTC (permalink / raw)
  To: scott.marlowe <scott.marlowe@ihs.com>; Bing Du <bdu@iastate.edu>; +Cc: pgsql-sql

use this

Last login: Fri Jan  9 16:54:14 from 192.168.2.117
[ssakkaravel@Linuxsvr ssakkaravel]$ psql -E training test
********* QUERY **********
SELECT usesuper FROM pg_user WHERE usename = 'test'
**************************

Welcome to psql, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help on internal slash commands
       \g or terminate with semicolon to execute query
       \q to quit

training=# \d books
********* QUERY **********
SELECT relhasindex, relkind, relchecks, reltriggers, relhasrules
FROM pg_class WHERE relname='books'
**************************

********* QUERY **********
SELECT a.attname, format_type(a.atttypid, a.atttypmod), a.attnotnull,
a.atthasdef, a.attnu
m
FROM pg_class c, pg_attribute a
WHERE c.relname = 'books'
  AND a.attnum > 0 AND a.attrelid = c.oid
ORDER BY a.attnum
**************************

********* QUERY **********
SELECT substring(d.adsrc for 128) FROM pg_attrdef d, pg_class c
WHERE c.relname = 'books' AND c.oid = d.adrelid AND d.adnum = 1
**************************

                                       Table "books"
   Column    |         Type          |                      Modifiers

-------------+-----------------------+--------------------------------------
--------------
--
 bid         | integer               | not null default
nextval('test.books_bid_seq'::text
)
 bname       | character varying(20) |
 price       | money                 |
 publication | date                  |



----- Original Message ----- 
From: "scott.marlowe" <scott.marlowe@ihs.com>
To: "Bing Du" <bdu@iastate.edu>
Cc: <pgsql-sql@postgresql.org>
Sent: Saturday, January 10, 2004 4:40 AM
Subject: Re: [SQL] how to show table structure?


> On Fri, 9 Jan 2004, Bing Du wrote:
>
> > Greetings,
> >
> > How can I see the layout of a table in PostgreSQL 7.4?  I've checked
> > several books and on-line documents, but was not able to figure out how
> > PostgreSQL does 'describe <table>' like it's done in other databases.
>
> If in psql, use the \d commands (\? will show you all of them.
>
> However, if you've not got psql to do it, you can look through the
> information_schema for anything like that, like so:
>
> select * from information_schema.tables;
>
> and so on.
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
>                http://archives.postgresql.org




^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2004-01-10 04:03 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-01-09 23:05 how to show table structure? Bing Du <bdu@iastate.edu>
2004-01-09 23:10 ` scott.marlowe <scott.marlowe@ihs.com>
2004-01-10 04:03   ` Kumar <sgnerd@yahoo.com.sg>
2004-01-09 23:12 ` Larry Rosenman <ler@lerctr.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