From: | "Ernesto Baschny" <ernst(at)baschny(dot)de> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | oid not "UNIQUE" for use as FOREIGN KEY? |
Date: | 2001-10-23 05:40:47 |
Message-ID: | 3BD51EFF.797.11112B@localhost |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi!
Imagine I have tables like those in PostgreSQL 7.1.3:
CREATE TABLE rabattgruppe (
gruppe_oid OID,
produktgruppe VARCHAR(256)
);
CREATE TABLE gruppe (
obergruppe_oid OID,
name VARCHAR(32)
);
Then I try to establish integrity check
ALTER TABLE gruppe ADD
FOREIGN KEY (obergruppe_oid) REFERENCES gruppe (oid);
But:
NOTICE: ALTER TABLE ... ADD CONSTRAINT will create implicit
trigger(s) for FOREIGN KEY check(s)
ERROR: UNIQUE constraint matching given keys for referenced
table "gruppe" not found
I thought the problem was I was referring to the same table,
but also this doesn't work:
ALTER TABLE rabattgruppe ADD
FOREIGN KEY (gruppe_oid) REFERENCES gruppe (oid);
NOTICE: ALTER TABLE ... ADD CONSTRAINT will create implicit
trigger(s) for FOREIGN KEY check(s)
ERROR: UNIQUE constraint matching given keys for referenced
table "gruppe" not found
Now, what is the problem? "oid" for sure should be an UNIQUE
field in each table, doesn't it? Is it a bug?
Thanks,
Ernesto
--
Ernesto Baschny <ernst(at)baschny(dot)de>
http://www.baschny.de - PGP Key:
http://www.baschny.de/pgp.txt
Sao Paulo/Brasil - Stuttgart/Germany
Ernst(at)IRCnet - ICQ# 2955403
From | Date | Subject | |
---|---|---|---|
Next Message | Erol Öz | 2001-10-23 05:46:18 | pg_dump - getTables() problem |
Previous Message | Hiroshi Inoue | 2001-10-23 05:19:50 | Re: [ODBC] Writing BLOBS to pgsql via ODBC using VB |