Re: Using oids

From: Alvaro Herrera Munoz <alvherre(at)dcc(dot)uchile(dot)cl>
To: Malcolm Warren <malcolm(at)villeinitalia(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Using oids
Date: 2003-09-03 15:03:41
Message-ID: 20030903150341.GD2452@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Wed, Sep 03, 2003 at 01:05:30PM +0200, Malcolm Warren wrote:

> I agree with you about database design and in fact fortunately I don't use
> oids as foreign keys, which I thought unwise. However I have found oids very
> useful as temporary unique references to a record in my programming. If I
> had known when I started writing my code three years ago that there was even
> the slightest doubt about continuing with oids then I wouldn't have used
> them.

You can create tables WITH OIDS (this is by default on 7.3, but will
probably changed in some future release). If you also create an unique
index on the oid column of the table, you have all you need. But beware
that some INSERTs will fail because the OID counter will wrap around at some
point. There is a non-zero probability that the newly generated OID will
collide with an existing tuple in that table; you have to be prepared to
repeat your query in that case, which can be a pain if you are doing
something else in the same transaction.

--
Alvaro Herrera (<alvherre[(at)]dcc(dot)uchile(dot)cl>)
"Lo esencial es invisible para los ojos" (A. de Saint Expery)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Phillips 2003-09-03 15:05:19 Re: Restarting, ownership, and permissions
Previous Message Amin Schoeib 2003-09-03 14:55:12 Re: Localization (for dates) Oracle vs. Postgresql

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera Munoz 2003-09-03 15:14:00 Re: ~* operator
Previous Message Darko Prenosil 2003-09-03 14:43:31 Re: libpq makefile for bcc