How do I disable referential integrity in Postgres 8.2?

There are two things you can do (these are complementary, not alternatives):

  • Create your foreign key constraints as DEFERRABLE. Then, call “SET CONSTRAINTS DEFERRED;”, which will cause foreign key constraints not to be checked until the end of the transaction. Note that the default if you don’t specify anything is NOT DEFERRABLE (annoyingly).
  • Call “ALTER TABLE mytable DISABLE TRIGGER ALL;”, which prevents any triggers executing while you load data, then “ALTER TABLE mytable ENABLE TRIGGER ALL;” when you’re done to re-enable them.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)