OID as Primary Key - Mailing list pgsql-general

From Jonas Bengtsson
Subject OID as Primary Key
Date
Msg-id 985264584.171jonas.b@home.se
Whole thread Raw
Responses Re: OID as Primary Key  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: OID as Primary Key  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
List pgsql-general
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?

Is it to prefer to use oid as PK? Or should I use SERIAL
instead? I thought it might be more efficient to use oid
and a waste of space to add another integer as PK.


Thanks in advance,
Jonas Bengtsson


pgsql-general by date:

Previous
From: Joel Burton
Date:
Subject: String REPLACE function
Next
From: "Grant Furick"
Date:
Subject: JOIN