pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: liste SQL <pgsql-sql@postgresql.org>
Subject: Re: referencing oid impozsible ?
Date: Tue, 11 Sep 2001 10:29:48 -0700
Message-ID: <web-117241@davinci.ethosmedia.com> (raw)
In-Reply-To: <3B9E269B.B56278F6@anpe.fr>




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



view thread (3+ messages)

Message-ID: <web-117241@davinci.ethosmedia.com>
Permalink:  ../web-117241@davinci.ethosmedia.com/
Also on:    postgresql.org/message-id/web-117241@davinci.ethosmedia.com

 · 

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: josh@agliodbs.com
  Subject: Re: referencing oid impozsible ?
  In-Reply-To: <web-117241@davinci.ethosmedia.com>

* 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