Re: How to add "on delete cascade" constraints

From: Raymond O'Donnell <rod(at)iol(dot)ie>
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 19:53:44
Message-ID: 4F9AF948.9030102@iol.ie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 27/04/2012 20:40, Alexander Farber wrote:
> So it's not a problem to drop and recreate the FOREIGN KEYs?

No, unless you're doing it on a production system, and someone inserts a
value that'll doesn't agree with the foreign key while it's gone.

Adding the constraint back in may take a while (depending on how big
your table is) as contents of the columns involved need to be checked to
ensure they contain valid values.

Also, I think maybe an exclusive lock is required, which will block out
other users - not sure about this - others on this list will know.

> And can I use START TRANSACTION while doing it?

Yes, absolutely - transactional DDL is one of PG's great strengths.

Ray.

--
Raymond O'Donnell :: Galway :: Ireland
rod(at)iol(dot)ie

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Richard Broersma 2012-04-27 20:18:57 Re: How to add "on delete cascade" constraints
Previous Message Merlin Moncure 2012-04-27 19:49:36 Re: how to execute a stored function that returns a boolean?