How to identify which column in a table is the primary key

From: "Scot L(dot) Harris" <webid(at)cfl(dot)rr(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: How to identify which column in a table is the primary key
Date: 2004-06-01 17:50:16
Message-ID: 1086112215.22794.49.camel@lathe
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I am using Postgresql 7.2.4 and php 4.2.2 to write some generic
functions to access and manipulate all tables in a database.

I have been looking for a way to identify the primary key defined in a
table. The closest I have found is a filed in the pg_class table that
is a boolean that tells me if that table has or every had a primary
key.

So given the table name is there a way to identify the column defined as
the primary key for that table?

--
Scot L. Harris <webid(at)cfl(dot)rr(dot)com>

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Frank Finner 2004-06-01 18:27:41 Re: Disappointing news
Previous Message Thomas Schoen 2004-06-01 17:47:41 ORDER BY with plpgsql parameter