How to see the definition of an existing table?
How to see the definition of an existing table?
От:
ke wang <kw68@cornell.edu>
Дата:
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
Re: How to see the definition of an existing table?
От:
Haller Christoph <ch@rodos.fzk.de>
Дата:
Within psql you can do commands like \d 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
Re: How to see the definition of an existing table?
От:
missive@frontiernet.net (Lee Harr)
Дата:
On Mon, 17 Sep 2001 14:51:52 +0000 (UTC), ke wang 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