Обсуждение: PRIMARY KEY not found?

Поиск
Список
Период
Сортировка

PRIMARY KEY not found?

От
"Vernon Smith"
Дата:
Here is the problem:

Table A ( id int, ...)
Table B ( ... ) inherits (A)

CREATE TABLE C ( id int REFERENCES B ON DELETE CASCADE, ...);

ERROR:  PRIMARY KEY for referenced table "B" not found

It is fine when the reference is table A.

Why?



____________________________________________________________
Get advanced SPAM filtering on Webmail or POP Mail ... Get Lycos Mail!
http://login.mail.lycos.com/r/referral?aid=27005

Re: PRIMARY KEY not found?

От
Stephan Szabo
Дата:
On Sat, 2 Aug 2003, Vernon Smith wrote:

>
> Here is the problem:
>
> Table A ( id int, ...)
> Table B ( ... ) inherits (A)
>
> CREATE TABLE C ( id int REFERENCES B ON DELETE CASCADE, ...);
>
> ERROR:  PRIMARY KEY for referenced table "B" not found
>
> It is fine when the reference is table A.
>
> Why?

I'm guessing that table A has a primary key on id?
Primary keys are not currently inherited, so you need to define
the key on B as well (and it doesn't guarantee uniqueness between
A and B)