Forum OpenACS Q&A: Response to Disable constraints in PG

Collapse
Posted by Jonathan Ellis on
to answer your original question, you can disable constraints on a table (in 7.2, I don't think you can do this in older versions) with
UPDATE "pg_class" SET "reltriggers" = 0 WHERE "relname" = 'mytable';
and to re-enable
UPDATE pg_class SET reltriggers =
    (SELECT count(*) FROM pg_trigger where pg_class.oid = tgrelid)
WHERE relname = 'mytable';
this is NOT how you want to solve your problem of deleting a few rows, but I mention it because it can be useful at other times, e.g. populating tables who each have a FK referencing the other.