pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Re: How to see the definition of an existing table?
3+ messages / 3 participants
[nested] [flat]

* Re: How to see the definition of an existing table?
@ 1970-01-01 00:00  Haller Christoph <ch@rodos.fzk.de>
  parent: ke wang <kw68@cornell.edu>
  1 sibling, 0 replies; 3+ messages in thread

From: Haller Christoph @ 1970-01-01 00:00 UTC (permalink / raw)
  To: kw68@cornell.edu; +Cc: pgsql-sql

Within psql you can do commands like 
\d <tablename>
to learn rudimentary information about 
a table. 

Try this to learn more sophisticated information 

select u.usename, t.typname, a.attname, a.atttypid, a.attlen, a.attnotnull, a.attnum 
from pg_user u, pg_type t, pg_attribute a 
where u.usesysid = t.typowner 
and t.typrelid = a.attrelid and t.typtype = 'c' and t.typname = 'pg_attribute' 

where 'pg_attribute' should be replaced by the table's name you 
are interested in. 

Unfortunately, I don't know nothing about how to find the primary key 
in a table definition. 
But go for the PostgreSQL documentation - Chapter System Catalogs - 
this should give you at least an idea which system catalog may 
deliver the information. 

Regards, Christoph 




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

* How to see the definition of an existing table?
@ 2001-09-15 00:35  ke wang <kw68@cornell.edu>
  0 siblings, 2 replies; 3+ messages in thread

From: ke wang @ 2001-09-15 00:35 UTC (permalink / raw)
  To: pgsql-sql

Is there any command or query to see the definition of an existing table,
like which is the primary key, which is not null etc.

Thanks!

--Ke




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

* Re: How to see the definition of an existing table?
@ 2001-09-18 00:37  Lee Harr <missive@frontiernet.net>
  parent: ke wang <kw68@cornell.edu>
  1 sibling, 0 replies; 3+ messages in thread

From: missive@frontiernet.net @ 2001-09-18 00:37 UTC (permalink / raw)
  To: pgsql-sql

On Mon, 17 Sep 2001 14:51:52 +0000 (UTC), ke wang <kw68@cornell.edu> wrote:
> Is there any command or query to see the definition of an existing table,
> like which is the primary key, which is not null etc.
> 

In psql:
\d tablename

to see what the exact query is, start psql with the -E flag:
psql -E
\d tablename




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


end of thread, other threads:[~2001-09-18 00:37 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-09-15 00:35 How to see the definition of an existing table? ke wang <kw68@cornell.edu>
1970-01-01 00:00 ` Haller Christoph <ch@rodos.fzk.de>
2001-09-18 00:37 ` Lee Harr <missive@frontiernet.net>

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