Re: How to identify which column in a table is the primary key - Mailing list pgsql-general

From Tom Lane
Subject Re: How to identify which column in a table is the primary key
Date
Msg-id 4938.1086117781@sss.pgh.pa.us
Whole thread Raw
In response to How to identify which column in a table is the primary key  ("Scot L. Harris" <webid@cfl.rr.com>)
List pgsql-general
"Scot L. Harris" <webid@cfl.rr.com> writes:
> So given the table name is there a way to identify the column defined as
> the primary key for that table?

You need to look in pg_index.

Note that the primary key could be a multicolumn index, so starting with
the assumption that there is "the column" is going to lead you on the
wrong track.

            regards, tom lane

pgsql-general by date:

Previous
From: Frank Finner
Date:
Subject: Re: Disappointing news
Next
From: Mike Nolan
Date:
Subject: Re: Running Totals and other stuff....