Re: How to get the primary key fields?

From: Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>
To: "Roberto (SmartBit)" <roberto(at)smartbit(dot)inf(dot)br>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to get the primary key fields?
Date: 2002-10-18 19:10:14
Message-ID: 1034968214.22016.18.camel@camel
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

SELECT c2.relname
FROM pg_class c, pg_class c2, pg_index i
WHERE c.relname = 'rms_users' AND c.oid = i.indrelid AND i.indexrelid =
c2.oid
AND i.indisprimary AND i.indisunique ORDER BY c2.relname

Robert Treat

On Fri, 2002-10-18 at 12:37, Roberto (SmartBit) wrote:
> Hi all
>
> how could I do a single select resulting a list of field name that are
> primary keys of a table??
>
> please, help me
>
> tia
>
> Roberto Amorim
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Teofilis Martisius 2002-10-18 19:18:40 Re: Performance problem iterating a resultset
Previous Message Bruce Momjian 2002-10-18 19:04:00 Re: PostgreSQL Benchmarks