Skip site navigation (1) Skip section navigation (2)

Re: How to detect primary key of a table

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: (view raw, whole thread or download thread mbox)
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:

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.

Michael Fuhr

In response to

pgsql-general by date

Next:From: jayati.biswasDate: 2006-03-30 11:55:34
Subject: Recovery with pg_xlog
Previous:From: Martijn van OosterhoutDate: 2006-03-30 11:38:07
Subject: Re: converting timstamptz to local time zone

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group