Re: OID as Primary Key

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Jonas Bengtsson <jonas(dot)b(at)home(dot)se>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: OID as Primary Key
Date: 2001-03-22 16:58:46
Message-ID: Pine.BSF.4.21.0103220851220.41849-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, 22 Mar 2001, Jonas Bengtsson wrote:

> Hello,
> I have problems with using OID as PK. I have created a
> UNIQUE INDEX on the oid on a relation called CourseEvents.
> The relation that is supposed to have a FK to CourseEvents
> is CourseEventsForums and it has a field called ceid which
> has oid as dtatype.
> But when I try to create a FK to that table I get following
> error:
> ---
> PostgreSQL said: ERROR: UNIQUE constraint matching given
> keys for referenced table "courseevents" not found
> Your query:
> ALTER TABLE CourseEventForums ADD CONSTRAINT
> RefCourseEvents43
> FOREIGN KEY (ceid)
> REFERENCES CourseEvents(oid)
> ---
> What is wrong?

The message is a bit misleading. Oid isn't a "user" column,
and currently you can only create references to user
columns. Given the issues involved with oid (since it's
system wide it rolls over faster than a serial, you have
to make sure to dump with oids, the fact that you have
much less control over its value if you need to do
something), I'm not 100% sure that's a bad thing, although
IIRC references to oid are on the todo list.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Mike Mascari 2001-03-22 17:03:00 RE: Re: OID as Primary Key
Previous Message Jonas Bengtsson 2001-03-22 16:54:15 RE: Re: OID as Primary Key