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
---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?
http://archives.postgresql.org