Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 35D3D9FA5F0 for ; Mon, 23 Oct 2006 16:04:39 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 82197-08 for ; Mon, 23 Oct 2006 19:04:34 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from web31806.mail.mud.yahoo.com (web31806.mail.mud.yahoo.com [68.142.207.69]) by postgresql.org (Postfix) with SMTP id 8BE7E9FA463 for ; Mon, 23 Oct 2006 16:04:34 -0300 (ADT) Received: (qmail 66798 invoked by uid 60001); 23 Oct 2006 19:04:33 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=llQuHp3AddRcsCznaDu0uk4yGukHxKDYPBnLmQSXicTfkjtOi16HxMNWo1HqdeyHvcxUk06FFAy4/eGf6GizZ8scwAoQ0FV3hSEjtHsXxtyZWqWvEgy+dXt2QpXFNQFYzT64+LKD7tjvpBRf38gwrEXqqJktIko5NXy2dX9v324= ; Message-ID: <20061023190433.66796.qmail@web31806.mail.mud.yahoo.com> Received: from [12.177.97.50] by web31806.mail.mud.yahoo.com via HTTP; Mon, 23 Oct 2006 12:04:33 PDT Date: Mon, 23 Oct 2006 12:04:33 -0700 (PDT) From: Richard Broersma Jr Subject: Re: delete on cascade To: Richard Broersma Jr , Luca Ferrari , pgsql-sql@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=3.355 tagged_above=0 required=5 tests=DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, DNS_FROM_RFC_WHOIS X-Spam-Level: *** X-Archive-Number: 200610/207 X-Sequence-Number: 26596 i guess my first attempt to send a reply failed. --- Richard Broersma Jr wrote: > > Hi all, > > I guess this is an already asked question, but I didn't found an answer, so > > apologize me. Imagine I've got two tables: > > skill(id,description) // primary key => id > > family(id,description) // primary key => id > > and I want to associate skills to families: > > ass_sf(id_skill,id_family) // appropriate foreign keys > > > > Tables are already created and the database is running. Now I'd like to > > implement a delete cascade, thus when I delete a skill also its association > > with the family must be deleted. I gues I should have declared the skill > > table as follows: > > CREATE TABLE skill > > ( > > id varchar(20) on delete cascade, > > description varchar(50), > > primary key(id) > > ); > > > > right? The problem is: how can I alter the table to add the column constraint > > now, without redeclaring the table? > > Thanks very much for helping me. > > This link has one line that is very similar to what you want to do. You will probably have to > start a transaction, drop the foriegn key contraint and then add a new foriegn key contraint > with > the on drop cascade . > > http://archives.postgresql.org/pgsql-general/2006-10/msg00467.php > > Regards, > > Richard Broersma Jr. > >