Re: How to temporarily disable a table's FK constraints? - Mailing list pgsql-general

From Ron Johnson
Subject Re: How to temporarily disable a table's FK constraints?
Date
Msg-id 472F53CB.1000707@cox.net
Whole thread Raw
In response to How to temporarily disable a table's FK constraints?  ("Kynn Jones" <kynnjo@gmail.com>)
List pgsql-general
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 11/05/07 10:50, Kynn Jones wrote:
> Hi, everyone.
>
> Is there a standard way to disable a table foreign-key constraint temporarily?
>
> I thought that this would be a fairly common thing to want to do, but
> I only found this snippet online:
>
> -- to disable
> UPDATE pg_class SET reltriggers=0 WHERE relname = 'your_table';
>
> -- to re-enable
> UPDATE pg_class SET reltriggers = count( * )
>   FROM pg_trigger WHERE pg_class.oid=tgrelid AND relname = 'your_table';
>
> and it appears that one needs to be root to execute these statements.
>
> Is there any other way for non-root users?

The whole idea of enforcing Relational Integrity in the database
engine is to *not* allow "regular users" to bypass data integrity
checks.

- --
Ron Johnson, Jr.
Jefferson LA  USA

Give a man a fish, and he eats for a day.
Hit him with a fish, and he goes away for good!

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD4DBQFHL1PLS9HxQb37XmcRAm7zAKDbdYSymz3zIyKmfdU5wPjtpVTAlwCYoEA/
DI1Z2Fbgo62k6C2P8gsCQQ==
=Np96
-----END PGP SIGNATURE-----

pgsql-general by date:

Previous
From: Erik Jones
Date:
Subject: Re: How to temporarily disable a table's FK constraints?
Next
From: Keith Carr
Date:
Subject: Bitemporal sequenced unique constraint (function/trigger)