Re: How to remove the current database and populate the database with new data?

From: "Wang, Mary Y" <mary(dot)y(dot)wang(at)boeing(dot)com>
To: "adrian(dot)klaver(at)gmail(dot)com" <adrian(dot)klaver(at)gmail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to remove the current database and populate the database with new data?
Date: 2010-06-03 23:26:05
Message-ID: FA20D4C4FEBFD148B1C0CB09913825FC04589DD6C3@XCH-SW-06V.sw.nos.boeing.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I thought about DROP DATABASE, but wasn't sure if it would clean up EVERYTHING.
I had a bad experience early this year when I restored a database that was running on Postgres 7.x.x. The database crashed badly, that I couldn't recover it. It ended up that I had to restore it from a previous night's backup. I noticed a huge decrease in performance after the restore. I always have thought that there was something that hasn't been cleaned up (Yes, I did run the VACUUM command). I decided not to investigate it anymore, because I already had a plan to upgrade to 8.3.8 anyway.

I assume most of you would just do the DROP DATABASE for the scenario that I described. Is that correct?

Mary

-----Original Message-----
From: Adrian Klaver [mailto:adrian(dot)klaver(at)gmail(dot)com]
Sent: Thursday, June 03, 2010 4:10 PM
To: pgsql-general(at)postgresql(dot)org
Cc: Wang, Mary Y
Subject: Re: [GENERAL] How to remove the current database and populate the database with new data?

On Thursday 03 June 2010 4:05:14 pm Wang, Mary Y wrote:
> Hi,
>
> I've some test data in a database and would like to delete that
> database and clean everything that is associated with that database.
> Then I'd like to populate the same database with different data. My plan is to:
> (1) Remove the /usr/local/pgsql/data directory
> (2) psql -e mydatabase -f /tmp/indumpfile.txt & > /tmp/outdumpfile.txt
> (/tmp/indumpfile.txt has all the sql statements to restore the
> database)
> (3) Restart the postgres server
>
> Not sure if I need to run the VACCUM command, because I know Postgres
> 8.3.8 has the auto-vacuum daemon on to perform VACCUMs when it's
> necessary. Did I miss any other steps for cleaning up?
>
> Please advise.
>
> Thanks
> Mary

Why not use DROP DATABASE? Removing the data directory removes the whole Postgres cluster, possibly including the config files.

--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message zhong ming wu 2010-06-03 23:30:47 Re: c program fails to run with the postgres which is installed at user location
Previous Message Adrian Klaver 2010-06-03 23:09:53 Re: How to remove the current database and populate the database with new data?