Re: delete on cascade

From: chester c young <chestercyoung(at)yahoo(dot)com>
To: Luca Ferrari <fluca1978(at)infinito(dot)it>
Cc: sql pgsql <pgsql-sql(at)postgresql(dot)org>
Subject: Re: delete on cascade
Date: 2006-10-23 15:41:25
Message-ID: 20061023154126.58178.qmail@web54307.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

--- Luca Ferrari <fluca1978(at)infinito(dot)it> 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.
> Luca

drop the constraint and re-declare it. (you can see the constraint
name by \dt skill from psql.)

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Stephan Szabo 2006-10-23 15:48:15 Re: delete on cascade
Previous Message Richard Broersma Jr 2006-10-23 15:41:16 Re: delete on cascade