Re: Finding the primary key of tables - Mailing list pgsql-general

From Merlin Moncure
Subject Re: Finding the primary key of tables
Date
Msg-id AANLkTinfcWxQ43uxK65tRAXYStAM5xBm91a7=rDz44zn@mail.gmail.com
Whole thread Raw
In response to Finding the primary key of tables  (George Silva <georger.silva@gmail.com>)
List pgsql-general
On Tue, Aug 3, 2010 at 3:13 PM, George Silva <georger.silva@gmail.com> wrote:
> Hello guys,
>
> I'm building a function which needs to know what is the primary key of a
> certain table (all in pgplsql).
>
> I was using select * from information_schema.key_column_usage where
> table_schema='foo' and table_name = 'aaa'; but that will give me multiple
> results in case of additional keys in the table.
>
> Any suggestions?

take a look at information_schema.table_constraint and match on constraint_name.

merlin

pgsql-general by date:

Previous
From: Greg Smith
Date:
Subject: Re: Question about Idle in TX
Next
From: David Kerr
Date:
Subject: Re: Question about Idle in TX