Re: adding on delete cascade constraint? - Mailing list pgsql-general

From Richard Huxton
Subject Re: adding on delete cascade constraint?
Date
Msg-id 200309191452.59650.dev@archonet.com
Whole thread Raw
In response to Re: adding on delete cascade constraint?  (Jean-Christian Imbeault <jc@mega-bucks.co.jp>)
List pgsql-general
On Friday 19 September 2003 14:02, Jean-Christian Imbeault wrote:
> Oliver Elphick wrote:
> >>Foreign Key constraints: $1 FOREIGN KEY (pid) REFERENCES products(id) ON
> >>UPDATE NO ACTION ON DELETE NO ACTION
> >
> > Drop the constraint; then add an amended one.
>
> Ok, how do I drop the constraint, it has no name.

Its name is "$1" - use

DROP CONSTRAINT "$1" ...

> Secondly what is the correct syntax for adding a new constraint with ON
> DELETE CASCADE?

See the SQL command reference for ALTER TABLE. It's something like:

ALTER TABLE mytable ADD CONSTRAINT constraint_name FOREIGN KEY ... etc

--
  Richard Huxton
  Archonet Ltd

pgsql-general by date:

Previous
From: Oliver Elphick
Date:
Subject: Re: adding on delete cascade constraint?
Next
From: Dennis Gearon
Date:
Subject: An idea for IPU ( We need another acronymn! )