Re: OID as Primary Key - Mailing list pgsql-general

From Stephan Szabo
Subject Re: OID as Primary Key
Date
Msg-id Pine.BSF.4.21.0103220851220.41849-100000@megazone23.bigpanda.com
Whole thread Raw
In response to OID as Primary Key  (Jonas Bengtsson <jonas.b@home.se>)
Responses RE: OID as Primary Key  ("Jonas Bengtsson" <jonas.b@home.se>)
List 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.



pgsql-general by date:

Previous
From: "Jonas Bengtsson"
Date:
Subject: RE: Re: OID as Primary Key
Next
From: "Jonas Bengtsson"
Date:
Subject: RE: OID as Primary Key