Re: A Table's Primary Key Listing - Mailing list pgsql-sql

From daq
Subject Re: A Table's Primary Key Listing
Date
Msg-id 170626266203.20050818172958@ugyvitelszolgaltato.hu
Whole thread Raw
In response to A Table's Primary Key Listing  (Roger Tannous <roger77_lb@yahoo.com>)
List 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])
frompg_indexwhere indisprimary and indrelid=(select oid from pg_class where relname='yourtable');
 
DAQ



pgsql-sql by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: A Table's Primary Key Listing
Next
From: "D'Arcy J.M. Cain"
Date:
Subject: Re: A Table's Primary Key Listing