disabling constraints

From: "David Parker" <dparker(at)tazznetworks(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: disabling constraints
Date: 2004-10-28 14:38:07
Message-ID: 07FDEE0ED7455A48AC42AC2070EDFF7C1492F3@corpsrv2.tazznetworks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
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
 

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Hallgren 2004-10-28 14:40:47 Re: Reasoning behind process instead of thread based
Previous Message Andrew Sullivan 2004-10-28 14:37:02 Re: compatibilityissues from 7.1 to 7.4