oid not "UNIQUE" for use as FOREIGN KEY?

Поиск
Список
Период
Сортировка
От Ernesto Baschny
Тема oid not "UNIQUE" for use as FOREIGN KEY?
Дата
Msg-id 3BD51EFF.797.11112B@localhost
обсуждение исходный текст
Ответы Re: oid not "UNIQUE" for use as FOREIGN KEY?  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Список 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@baschny.de>
 http://www.baschny.de - PGP Key:
http://www.baschny.de/pgp.txt
 Sao Paulo/Brasil - Stuttgart/Germany
 Ernst@IRCnet - ICQ# 2955403


В списке pgsql-general по дате отправления:

Предыдущее
От: Keary Suska
Дата:
Сообщение: UNION bug in 7.1.3?
Следующее
От: Hiroshi Inoue
Дата:
Сообщение: Re: [ODBC] Writing BLOBS to pgsql via ODBC using VB