Re: Alter table to "on update cascade"

From: Richard Broersma <richard(dot)broersma(at)gmail(dot)com>
To: David Fetter <david(at)fetter(dot)org>
Cc: Aram Fingal <fingal(at)multifactorial(dot)com>, Postgres-General General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Alter table to "on update cascade"
Date: 2010-11-17 17:42:55
Message-ID: AANLkTim0_j4QhMxm0PQ22MuOXR4iPW1zz=t5PYeRUX_1@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Nov 17, 2010 at 8:43 AM, David Fetter <david(at)fetter(dot)org> wrote:

> You can do it like this:
>
> BEGIN;
> ALTER TABLE foo DROP CONSTRAINT your_constraint;
> ALTER TABLE foo ADD FOREIGN KEY ...;
> COMMIT;

The nice thing about the ALTER TABLE statement is that you can do it
in one command:

ALTER TABLE foo
DROP CONSTRAINT your_constraint,
ADD CONSTRAINT your_constraint FOREIGN KEY ...
ON UPDATE CASCADE ON DELETE RESTRICT;

--
Regards,
Richard Broersma Jr.

Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Allan Kamau 2010-11-17 17:44:16 Trying to obtain the intersect of two tsvector values
Previous Message David Fetter 2010-11-17 17:24:26 Re: Re: Storing old and new tuple values after an UPDATE, INSERT or DELETE