Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f8BHTo705585 for ; Tue, 11 Sep 2001 13:29:51 -0400 (EDT) (envelope-from josh@agliodbs.com) Received: from [209.10.40.250] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.4.1) with HTTP id 117241 for ; Tue, 11 Sep 2001 10:29:48 -0700 From: "Josh Berkus" Subject: Re: referencing oid impozsible ? To: liste SQL X-Mailer: CommuniGate Pro Web Mailer v.3.4.1 Date: Tue, 11 Sep 2001 10:29:48 -0700 Message-ID: In-Reply-To: <3B9E269B.B56278F6@anpe.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Archive-Number: 200109/56 X-Sequence-Number: 4702 Patrick, > I tried recently (pgsql 7.1.2) to establish the oid of one table as > foreign key > in another. > To no avail : there was no uniqueness constraint on that column > Naturally, it seems impossible to add a uniqueness constraint to such > a system > column. > As far as i know, the oid is by nature unique, excepting for the case > of > wrapping of their sequence. > Is there any workaround ? Yes. Don't use the OID as your key. While it would be entirely possible for you add a unique constraint to the OID column, you do not want to use it as your key for a number of reasons previously discussed on this list (OID wraparound, problems with backup and restore, etc.). Instead, re-create the table with a new ID column of type SERIAL with a PRIMARY KEY constraint. This will automatically create an auto-incrementing sequence of unique values perfect for attaching foriegn keys. -Josh ______AGLIO DATABASE SOLUTIONS___________________________ Josh Berkus Complete information technology josh@agliodbs.com and data management solutions (415) 565-7293 for law firms, small businesses fax 621-2533 and non-profit organizations. San Francisco