Re: can you change an FK constraint from NOT DEFERRABLE to DEFERRABLE - Mailing list pgsql-sql

From Greg Stark
Subject Re: can you change an FK constraint from NOT DEFERRABLE to DEFERRABLE
Date
Msg-id 87sm2cwxwb.fsf@stark.xeocode.com
Whole thread Raw
In response to Re: can you change an FK constraint from NOT DEFERRABLE to DEFERRABLE  (Bruno Wolff III <bruno@wolff.to>)
List pgsql-sql
Bruno Wolff III <bruno@wolff.to> writes:

> It does look like you can only ADD and DROP constraints, not directly
> alter or replace them. So making a reference deferable is go to require
> a DROP and ADD which will need to recheck the constraint.

I asked the same question a few days ago on pgsql-general.

In short, if you want to skip the rechecking you have to update system tables
directly and you have to do two of them. 

The updates you want would look something like these. But these would do *all*
your constraints, make sure to get only the ones you really want to change:

update pg_constraint set condeferrable = 't' where contype = 'f'
update pg_trigger set tgdeferrable=true where tgisconstraint = true


I think an ALTER CONSTRAINT to change these settings as well as the 
ON {UPDATE,DELETE} behaviour would be neat.

-- 
greg



pgsql-sql by date:

Previous
From: "Joel Fradkin"
Date:
Subject: Re: delphi access question?
Next
From: Chris Browne
Date:
Subject: Re: New record position