Re: A Table's Primary Key Listing

From: daq <daq(at)ugyvitelszolgaltato(dot)hu>
To: Pgsql-sql(at)postgresql(dot)org
Subject: Re: A Table's Primary Key Listing
Date: 2005-08-18 15:29:58
Message-ID: 170626266203.20050818172958@ugyvitelszolgaltato.hu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


RT> Hi to all,

RT> Is there any means to get a list of the Primary Keys (or simply the
RT> Primary Key if there's only one :) ) for a given table using an SQL query
RT> ?

RT> Regards,
RT> Roger Tannous.

Something like this?

select (select attname from pg_attribute where attrelid=pg_index.indrelid and pg_attribute.attnum=pg_index.indkey[0]) from pg_index
where indisprimary and indrelid=(select oid from pg_class where relname='yourtable');

DAQ

Browse pgsql-sql by date

  From Date Subject
Next Message D'Arcy J.M. Cain 2005-08-18 16:18:44 Re: A Table's Primary Key Listing
Previous Message Michael Fuhr 2005-08-18 15:05:46 Re: A Table's Primary Key Listing