Re: can you change an FK constraint from NOT DEFERRABLE to DEFERRABLE

From: Greg Stark <gsstark(at)mit(dot)edu>
To: Bruno Wolff III <bruno(at)wolff(dot)to>
Cc: Michael Fuhr <mike(at)fuhr(dot)org>, frank(at)joerdens(dot)de, pgsql-sql(at)postgresql(dot)org
Subject: Re: can you change an FK constraint from NOT DEFERRABLE to DEFERRABLE
Date: 2005-03-30 22:51:16
Message-ID: 87sm2cwxwb.fsf@stark.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Bruno Wolff III <bruno(at)wolff(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Chris Browne 2005-03-30 23:04:27 Re: New record position
Previous Message Joel Fradkin 2005-03-30 21:36:22 Re: [SQL] delphi access question?