From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | Sergey Karin <sergey(dot)karin(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: How to detect primary key of a table |
Date: | 2006-03-30 11:40:48 |
Message-ID: | 20060330114048.GA7391@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thu, Mar 30, 2006 at 03:13:12PM +0400, Sergey Karin wrote:
> Are there any abilities to detect primary key of a table?
In psql you could use "\d tablename". To see the queries that psql
makes, execute "\set ECHO_HIDDEN" and then "\d tablename". Here's
the documentation for the system catalogs that psql queries:
http://www.postgresql.org/docs/8.1/interactive/catalogs.html
You could also query the Information Schema; table_constraints
joined with key_column_usage or constraint_column_usage should
yield a table's primary key columns.
http://www.postgresql.org/docs/8.1/interactive/information-schema.html
--
Michael Fuhr
From | Date | Subject | |
---|---|---|---|
Next Message | jayati.biswas | 2006-03-30 11:55:34 | Recovery with pg_xlog |
Previous Message | Martijn van Oosterhout | 2006-03-30 11:38:07 | Re: converting timstamptz to local time zone |