disabling constraints

David Parker <dparker@tazznetworks.com>

From: "David Parker" <dparker@tazznetworks.com>
To: <pgsql-general@postgresql.org>
Date: 2004-10-28T14:38:07Z
Lists: pgsql-general
I would like to be able to truncate all of the tables in a schema without worrying about FK constraints. I tried issuing a "SET CONSTRAINTS ALL DEFERRED" before truncating, but I still get constraint errors. Is there a way to do something like:

1) disable all constraints
2) truncate all tables
3) re-enable all constraints

?

In the slony project there is a procedure "altertableforreplication" that appears to do 1), but since it is updating pg_catalog tables directly, I don't want to cut/paste before I understand what it's doing!

Is there any "standard" way of doing this?

- DAP
----------------------------------------------------------------------------------
David Parker    Tazz Networks    (401) 709-5130