Re: Constraints/On Delete...

Поиск
Список
Период
Сортировка
От Boget, Chris
Тема Re: Constraints/On Delete...
Дата
Msg-id 4040BBE81A9AD411BD27009027887A7C0431CA@tiger.wild.net
обсуждение исходный текст
Ответ на Constraints/On Delete...  ("Boget, Chris" <chris@wild.net>)
Ответы Re: Constraints/On Delete...  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Список pgsql-general

> You don't alter first.  You need to drop the constraint on
> second and add a new constraint on second with on delete
> cascade.

Could you give me an example of this?  This is what I tried:

ALTER TABLE "second" ADD CONSTRAINT "secondfk"
FOREIGN KEY (record_num) REFERENCES "first"("record_num")
ON DELETE CASCADE

which gave me this error:

ERROR: secondfk referential integrity violation - key referenced
from second not found in first

What am I doing wrong?

Also, from the looks of it, it seems like what will happen is
when records from "second" are deleted, the referenced records
in "first" will be deleted, too.  Is this the case?  If so,
what I want to happen is that when records are deleted in the
"first table" (the root or parent table, if you will), records
will also be deleted in the "second" table.  Again, if so, how
do I go about setting this functionality up?

Chris

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

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: Constraints/On Delete...
Следующее
От: Stephan Szabo
Дата:
Сообщение: Re: Constraints/On Delete...