Re: disabling constraints - Mailing list pgsql-general

From Tom Lane
Subject Re: disabling constraints
Date
Msg-id 29453.1099600592@sss.pgh.pa.us
Whole thread Raw
In response to Re: disabling constraints  (Vivek Khera <khera@kcilink.com>)
List pgsql-general
Vivek Khera <khera@kcilink.com> writes:
> "DP" == David Parker <dparker@tazznetworks.com> writes:
> DP> I would like to be able to truncate all of the tables in a schema
> DP> without worrying about FK constraints. I tried issuing a "SET
> DP> CONSTRAINTS ALL DEFERRED" before truncating, but I still get
> DP> constraint errors. Is there a way to do something like:

> Why don't you truncate your tables in an order that won't violate
> FK's?  Or do you have circular references?

The TRUNCATE command just says "no" if it sees any FKs pointing at the
target table; order doesn't matter.

It might be an interesting future extension to allow truncating multiple
tables in a single command, whereupon we could ignore FKs linking two
such tables.

            regards, tom lane

pgsql-general by date:

Previous
From: "David Parker"
Date:
Subject: Re: disabling constraints
Next
From: Timothy Perrigo
Date:
Subject: Re: PostgreSQL on Linux PC vs MacOS X