X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E4B8B8BA0EC for ; Tue, 15 Feb 2005 19:03:42 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 99911-04 for ; Tue, 15 Feb 2005 19:03:38 +0000 (GMT) Received: from mail.libertyrms.com (unknown [207.219.45.62]) by svr1.postgresql.org (Postfix) with ESMTP id AB0698BA0F6 for ; Tue, 15 Feb 2005 19:03:37 +0000 (GMT) Received: from dba5.int.libertyrms.com ([10.1.3.44]) by mail.libertyrms.com with esmtp (Exim 4.22) id 1D17yz-00059F-2n for pgsql-admin@postgresql.org; Tue, 15 Feb 2005 14:03:37 -0500 Message-ID: <42124788.8080500@ca.afilias.info> Date: Tue, 15 Feb 2005 14:03:36 -0500 From: Brad Nicholson User-Agent: Mozilla Thunderbird 0.8 (X11/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: PostgreSQL Admin Subject: Re: empty a database References: <42123059.2070505@eldocomp.com> In-Reply-To: <42123059.2070505@eldocomp.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-SA-Exim-Mail-From: bnichols@ca.afilias.info X-SA-Exim-Scanned: No; SAEximRunCond expanded to false X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.015 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200502/126 X-Sequence-Number: 16294 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 [0232 16:32]: >> >> >> >>>Dick Davies 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... >> >> >> >> > > > >