Re: Constraints/On Delete...

From: "Boget, Chris" <chris(at)wild(dot)net>
To: "'Stephan Szabo '" <sszabo(at)megazone23(dot)bigpanda(dot)com>
Cc: "''pgsql-general(at)postgresql(dot)org' '" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Constraints/On Delete...
Date: 2003-01-04 16:41:05
Message-ID: 4040BBE81A9AD411BD27009027887A7C0431CA@tiger.wild.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2003-01-04 16:48:12 Re: Constraints/On Delete...
Previous Message Stephan Szabo 2003-01-04 16:21:07 Re: Constraints/On Delete...