From: | Surfing <onlinesurfing(at)gmail(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Function to total reset a schema |
Date: | 2011-05-29 08:03:36 |
Message-ID: | 4DE1FDD8.2080309@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
I have two schemas, so I can't do that ...
@ Scott. You are totally right ... I have just read this on the
documentation:
"TRUNCATE quickly removes all rows from a set of tables. It has the same
effect as an unqualified
DELETE on each table, but since it does not actually scan the tables it
is faster. Furthermore, it reclaims
disk space immediately, rather than requiring a subsequent VACUUM
operation. This is most useful on
large tables."
So the VACUUM should not really be necessary..thanks.
Il 29/05/2011 09:54, Thomas Kellerer ha scritto:
> Surfing wrote on 29.05.2011 09:38:
>> Hi all,
>> I need to write a function that totally empty a schema.
>>
>> So I have written a TRUNCATE statement for each table and set to 0
>> each sequence.
>> Btw, it could be good to execute a vacuum statement on each table,
>> but from within the function this is not allowed.
>>
>> Is there a way to obtain the same result in another way (without
>> using the vacuum)?
>>
>
> If you are only using a single schema in your database, you could
> create an empty database with all your tables that you then use as the
> template database when creating a new one:
>
> Then each time you want to reset your schema (=database) you do a
>
> drop database real_database;
> create database real_database template template_database;
>
> Then you don't need to adjust your "reset" script if your database
> changes (you only maintain the template database using your SQL scripts)
>
> Thomas
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Enrico Weigelt | 2011-05-30 07:39:50 | Re: [SQL] 500KB PDF files for postgresql8.3, which is the most efficient way? |
Previous Message | Thomas Kellerer | 2011-05-29 07:54:41 | Re: Function to total reset a schema |