Received: from styx.apartia.int (postfix@dyn-1-1-100.Vin.dialup.oleane.fr [195.25.4.100]) by hub.org (8.9.3/8.9.3) with ESMTP id LAA17268 for ; Sat, 3 Jun 2000 11:52:40 -0400 (EDT) (envelope-from cunctator@apartia.ch) Received: by styx.apartia.int (Postfix, from userid 1000) id B98FA44C6; Sat, 3 Jun 2000 17:51:56 +0200 (CEST) Date: Sat, 3 Jun 2000 17:51:56 +0200 From: Louis-David Mitterrand To: pgsql-general@postgresql.org Subject: Re: child table doesn't inherit PRIMARY KEY? Message-ID: <20000603175156.A4073@styx> Reply-To: ldm@apartia.com Mail-Followup-To: pgsql-general@postgresql.org References: <20000603172256.A3435@styx> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2i In-Reply-To: <20000603172256.A3435@styx>; from cunctator@apartia.ch on Sat, Jun 03, 2000 at 05:22:56PM +0200 X-Archive-Number: 200006/95 On Sat, Jun 03, 2000 at 05:22:56PM +0200, Louis-David Mitterrand wrote: > When creating a child (through CREATE TABLE ... INHERIT (parent)) it > seems the child gets all of the parent's contraints _except_ its PRIMARY > KEY. Is this normal? Should I add a PRIMARY KEY(id) statement each time > I create an inherited table? Following up to my previous message, I found that one can't explicitely add a PRIMARY KEY on child table referencing a field on the parent table, for instance: CREATE TABLE auction ( id SERIAL PRIMARY KEY, title text, ... etc... ); then CREATE TABLE auction_dvd ( zone int4, PRIMARY KEY("id") ) inherits("auction"); doesn't work: ERROR: CREATE TABLE: column 'id' named in key does not exist But the aution_dvd table doesn't inherit the auction table's PRIMARY KEY, so I can insert duplicates. Solutions: 1) don't use PRIMARY KEY, use UNIQUE NOT NULL (which will be inherited?) but the I lose the index, 2) use the OID field, but it's deprecated by PG developers? What would be the best solution? TIA -- Louis-David Mitterrand - ldm@apartia.org - http://www.apartia.fr Veni, Vidi, VISA.