pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Brad Nicholson <bnichols@ca.afilias.info>
To: PostgreSQL Admin <pgsql-admin@postgresql.org>
Subject: Re: empty a database
Date: Tue, 15 Feb 2005 14:03:36 -0500
Message-ID: <42124788.8080500@ca.afilias.info> (raw)
In-Reply-To: <42123059.2070505@eldocomp.com>
References: <42123059.2070505@eldocomp.com>

If there are any foreign key constraints, you'll have to truncate the 
tables in the appropriate order.  You would also have to reset the 
sequence values as well.

Naomi Walker wrote:

>How about just truncating all the tables?
>
>
>Dick Davies wrote:
>  
>
>>* Tom Lane <tgl@sss.pgh.pa.us> [0232 16:32]:
>>
>>    
>>
>>>Dick Davies <rasputnik@hellooperator.net> writes:
>>>
>>>      
>>>
>>>>Is there a neat way to clean out a database via SQL commands?
>>>>i.e. get rid of tables, sequences, integers, etc.
>>>>        
>>>>
>>>>At present I'm using dropdb/createdb, but thats' far from ideal
>>>>and I think it's causing postgres to do more mork than it needs to...
>>>>        
>>>>
>>>Well, if you put everything into one or a few schemas then dropping
>>>and recreating those schemas would do it.  I suspect though that this
>>>is *not* faster than dropdb/createdb.
>>>      
>>>
>>Thanks Tom.
>>
>>It's not just the speed, it's the constant deletes and creations in
>>~pgsql/data - as I said the other day, this is recreating a test db from the
>>production one as part of unit tests, so this happens dozens of times a day...
>>
>>
>>    
>>
>
>
>  
>




view thread (7+ messages)  latest in thread

Message-ID: <42124788.8080500@ca.afilias.info>
Permalink:  ../42124788.8080500@ca.afilias.info/
Also on:    postgresql.org/message-id/42124788.8080500@ca.afilias.info

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: bnichols@ca.afilias.info
  Subject: Re: empty a database
  In-Reply-To: <42124788.8080500@ca.afilias.info>
  References: <42123059.2070505@eldocomp.com> <42124788.8080500@ca.afilias.info>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox