Re: Using oids - Mailing list pgsql-general

From Alvaro Herrera Munoz
Subject Re: Using oids
Date
Msg-id 20030903150341.GD2452@dcc.uchile.cl
Whole thread Raw
In response to Re: Using oids  (Malcolm Warren <malcolm@villeinitalia.com>)
List pgsql-general
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[@]dcc.uchile.cl>)
"Lo esencial es invisible para los ojos" (A. de Saint Ex�pery)

pgsql-general by date:

Previous
From: Jeff Eckermann
Date:
Subject: Re: Oracle decode Function in Postgres
Next
From: Vivek Khera
Date:
Subject: Re: Commercial postgresql