Re: How to add "on delete cascade" constraints

From: Richard Broersma <richard(dot)broersma(at)gmail(dot)com>
To: Alexander Farber <alexander(dot)farber(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to add "on delete cascade" constraints
Date: 2012-04-27 20:18:57
Message-ID: CABvLTWFTM8yRk=Ns2Bn++GH2WWLDfF50FM-tOXUw95vD+o8e+A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Apr 27, 2012 at 12:40 PM, Alexander Farber
<alexander(dot)farber(at)gmail(dot)com> wrote:
> So it's not a problem to drop and recreate the FOREIGN KEYs?
>
> And can I use START TRANSACTION while doing it?

You could, but you don't need to since you can do all of this is one statement:

ALTER TABLE public.pref_scores
DROP CONSTRAINT pref_scores_gid_fkey,
ADD CONSTRAINT pref_scores_gid_fkey
FOREIGN KEY (gid)
REFERENCES pref_games(gid)
ON DELETE CASCADE;

--
Regards,
Richard Broersma Jr.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alexander Farber 2012-04-27 20:25:23 Re: How to add "on delete cascade" constraints
Previous Message Raymond O'Donnell 2012-04-27 19:53:44 Re: How to add "on delete cascade" constraints