Re: "truncate all"?

From: "Shridhar Daithankar" <shridhar_daithankar(at)persistent(dot)co(dot)in>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: "truncate all"?
Date: 2003-08-04 09:40:24
Message-ID: 3F2E7760.30021.23D00108@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 4 Aug 2003 at 11:25, Andreas wrote:
> Would it be possible to implement a "truncate all" that purges all tuples
> from *all* tables, without taking account any rules or triggers, but
> leaving all table structures and rules, triggers, functions, etc intact
> (sequences do not need to reinitialized)?
>
> As far as I understand, the "no truncate if table is referenced" change was
> introduced to ensure database integrity. However, if the referencing table
> is truncated, too, there should be no problem as far as foreign keys are
> concerned, correct?
>
> The rationale behind this suggestion is that in our project we need a
> *quick* way to get rid of all the tuples in all tables in order to
> accelerate the reinitialization of the database for our unit tests. This
> needs to be done fairly often, and so the quicker the unit tests run, the
> easier it will be to include many unit tests in our project, thus ensuring
> that we can develop efficiently and safely in postgresql.
>
> If you know of some other *quick* way to truncate all tables, please let us
> know. BTW: Starting and later rolling back a transaction will not work, as

As a workaround, I would dump the schema to a file using pg_dump, drop the
database and recreate it from schema.

Will that do for you? Unfortunately that is not transaction safe and any
clients connected at that time needs to disconnect first. Hopefully you can do
that in the test environment.

HTH

Bye
Shridhar

--
Bubble Memory, n.: A derogatory term, usually referring to a person's
intelligence. See also "vacuum tube".

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Lee Kindness 2003-08-04 10:25:36 Re: 7.4 COPY BINARY Format Change
Previous Message Andreas 2003-08-04 09:25:56 "truncate all"?