Re: EMPTYING A DATABASE

Поиск
Список
Период
Сортировка
От Greg Sabino Mullane
Тема Re: EMPTYING A DATABASE
Дата
Msg-id 9cda64505220d8e81b7096e795ae3b57@biglumber.com
обсуждение исходный текст
Ответ на EMPTYING A DATABASE  (JORGE MALDONADO <jorgemal1960@gmail.com>)
Ответы Re: EMPTYING A DATABASE  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-novice
-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160


> I am developing a project in which, of course, information is fed to the DB
> for testing purposes and sometimes I need to get the DB clean, without any
> record.
> What would be the best practice to delete all of the records and start
> testing with a blank DB?

Your best bet is to recreate the database. Start with an database that has all
the tables already emptied out, then make a copy of it. Then drop and
recreate your database at will using the copy as a template. So, if your
datbase was named "alpha", you would do (one time only):

(truncate all tables, get the alpha database in a clean state)
CREATE DATABASE alpha_template TEMPLATE alpha;

Then, every time you want to create a clean copy, do:

DROP DATABASE alpha;
CREATE DATABASE alpha TEMPLATE alpha_template;

- --
Greg Sabino Mullane greg@turnstep.com
End Point Corporation http://www.endpoint.com/
PGP Key: 0x14964AC8 201004291214
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----

iEYEAREDAAYFAkvZsRwACgkQvJuQZxSWSsifxQCgro7N0RTnNk5wla+GZg2J5fji
ifAAoMxzOZwnkeYSi4BHhkXFGru1AMrL
=/yIr
-----END PGP SIGNATURE-----



В списке pgsql-novice по дате отправления:

Предыдущее
От: JORGE MALDONADO
Дата:
Сообщение: EMPTYING A DATABASE
Следующее
От: Tom Lane
Дата:
Сообщение: Re: EMPTYING A DATABASE