Finding the primary key of tables

From: George Silva <georger(dot)silva(at)gmail(dot)com>
To: PGSQL Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Finding the primary key of tables
Date: 2010-08-03 19:13:07
Message-ID: AANLkTin5e4ybJHwVRO3R4JvM=Zb2RD+mH+=USjA5TiAy@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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?

--
George R. C. Silva

Desenvolvimento em GIS
http://blog.geoprocessamento.net

Responses

Browse pgsql-general by date

  From Date Subject
Next Message John R Pierce 2010-08-03 19:17:42 Re: Question about Idle in TX
Previous Message David Kerr 2010-08-03 19:13:01 Question about Idle in TX