Re: Modifying FK constraints

From: Richard Huxton <dev(at)archonet(dot)com>
To: Oleg Lebedev <oleglebedev(at)waterford(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Modifying FK constraints
Date: 2004-11-10 17:22:52
Message-ID: 41924E6C.8050400@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Oleg Lebedev wrote:
> Greetings.
>
> Is it possible to modify a foreign key constraint and force it to
> cascade on update? If there is no such SQL command, then is it possible
> to update some system tables to accomplish this?

BEGIN;
ALTER TABLE t1 DROP CONSTRAINT ...
ALTER TABLE t1 ADD CONSTRAINT ...
COMMIT;

Note that this will trigger a re-examination of all the values to check
the constraint is valid.

Also you may have to quote constraint names. If they are generated as $1
you will need to refer to them as "$1".

Full details in the "SQL Commands" chapter under "ALTER TABLE"
--
Richard Huxton
Archonet Ltd

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Mike Nolan 2004-11-10 17:29:52 Re: Important Info on comp.databases.postgresql.general
Previous Message Oleg Lebedev 2004-11-10 17:00:02 Modifying FK constraints