How to turn off referential integrity
Apr 8, 2002 at 5:17 pm
I am using Postgresql 7.2 -- I would like to know how to turn off the
referential integrity of tables so that I can
do a bulk load & then turn the referential integrity back on.
Thanks very much
Joshua b. Jore
: I have two functions for just that trick. I'm retyping this from another screen so there may be a typo or two. The DisableTriggers() function does more work than it has to - I copied the joins from the EnableTriggers() function which does need the extra joins. The key is, just set pg_class.reltriggers to either 0 or the correct number of triggers. Josh DROP FUNCTION DisableTriggers(); CREATE FUNCTION DisableTriggers() RETURNS BOOLEAN AS ' DECLARE Rows INTEGER; BEGIN UPDATE pg_class SET
: There's a little dance you can do involving disabling and then re-enabling the triggers that enforce RI. The easiest example is to do a "pg_dump -a" (data only) dump from a small table and look to see how pg_dump does it. IIRC, you don't need to touch the triggers themselves, just hit the pg_class field that says whether the table has triggers. regards, tom lane
Question about Referential Integrity in Microsoft Access and Postgres tables linked tables via ODBC
Renaming unnamed FK constraints
Suspend Referential Integrity?
referential integrity for insert
foreign key violation
triggers and indexes.
Re: How can I do this?
referential integrity and permissions
1 of 3
Apr 8, '02 at 5:17p
Apr 8, '02 at 7:20p
3 users in discussion
Joshua b. Jore (1)
Tom Lane (1)
Pam Wampler (1)
Groups & Organizations
site design / logo © 2022 Grokbase