pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David BOURIAUD <david.bouriaud@ac-rouen.fr>
To: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: About primary keys.
Date: Tue, 19 Jun 2001 14:50:22 +0200
Message-ID: <3B2F4A8E.B6E07DBB@ac-rouen.fr> (raw)
References: <20010619123625.F01A21A78@druid.net>

"D'Arcy J.M. Cain" wrote:
> 
> Thus spake David BOURIAUD
> > Is there a way to get in system tables all the primary keys of a table ?
> > Thanks by advance.
> 
> SELECT pg_class.relname, pg_attribute.attname
>     FROM pg_class, pg_attribute, pg_index
>     WHERE pg_class.oid = pg_attribute.attrelid AND
>         pg_class.oid = pg_index.indrelid AND
>         pg_index.indkey[0] = pg_attribute.attnum AND
>         pg_index.indisprimary = 't'
> 
> Caveat:  Does not work for complex primary keys.

Thanks, but that is my problem actually !
I've got few tables that have complex primary keys. I know that this
shouldn't be, but I have to work with it (no choice, much pain !). Since
I've got to write a php program that will have to work for both type of
tables (many with simple keys, and few with complex ones), how can I
have a same querry work with both ?

-- 
David BOURIAUD
----------------------------------------------------------
In a world without walls or fences, what use do we have 
for windows or gates ?
----------------------------------------------------------
ICQ#102562021



view thread (9+ messages)  latest in thread

Message-ID: <3B2F4A8E.B6E07DBB@ac-rouen.fr>
Permalink:  ../3B2F4A8E.B6E07DBB@ac-rouen.fr/
Also on:    postgresql.org/message-id/3B2F4A8E.B6E07DBB@ac-rouen.fr

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: david.bouriaud@ac-rouen.fr
  Subject: Re: About primary keys.
  In-Reply-To: <3B2F4A8E.B6E07DBB@ac-rouen.fr>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox