X-Original-To: pgsql-admin-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 5DADD9FB1BA for ; Sun, 18 Jun 2006 22:03:02 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 38527-05 for ; Sun, 18 Jun 2006 22:02:53 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from web31115.mail.mud.yahoo.com (web31115.mail.mud.yahoo.com [68.142.201.77]) by postgresql.org (Postfix) with SMTP id CD3C29FA45F for ; Sun, 18 Jun 2006 22:02:52 -0300 (ADT) Received: (qmail 70187 invoked by uid 60001); 19 Jun 2006 01:02:50 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=HwJPtbIVRaSSxkkr0+GqBKhc1H20jVV5FF2wLj0UFJqKljjqCrShoo4sOeP/pSu6hnCmsSOL/fSepWR/MnUoJzZGYBYD44WnZ2s9qfP7p0ZuQL+Kh6orDEftge9TOqCshhrOd8ByTliMdkTmrSJKMRO0+ZXun/RTJLgfhvf0SaM= ; Message-ID: <20060619010250.70185.qmail@web31115.mail.mud.yahoo.com> Received: from [218.111.21.13] by web31115.mail.mud.yahoo.com via HTTP; Sun, 18 Jun 2006 18:02:50 PDT Date: Sun, 18 Jun 2006 18:02:50 -0700 (PDT) From: Infor Gates Subject: Re: pg_restore To: Aaron Bono , Tom Lane Cc: Infor Gates , pgsql-admin@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1830066886-1150678970=:69850" Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/145 X-Sequence-Number: 22107 --0-1830066886-1150678970=:69850 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Thanks Aaron I am trying to do exactly the same thing. Now that my understanding of pg_restore is clearer. I was worried by my index key table was corrupted somehow and caused the error message. This is the cause by my own misunderstanding. CY Aaron Bono wrote: I agree. When restoring a database from back up, I do a drop database and recreate it to make sure everything is properly intact (tables, columns, views, triggers, foreign keys, etc...). We do this a lot for testing. We backup the production database, copy to test server and do a restore on the test database. It helps us test our code rollouts. -Aaron On 6/18/06, Tom Lane wrote: Infor Gates writes: > I am having the impression that pg_restore would over-rides the "old" > data with the current one. Is my thinking wrong? Yeah. By default, pg_restore will issue a CREATE TABLE (which of course fails if the table already exists) followed by COPY (which just tries to insert data in addition to what might be there already). There's a command line option to ask pg_restore to try to DROP TABLE before doing the CREATE TABLE. By and large, though, that's a bad way to proceed unless you are specifically trying to merge two databases. The fast and easy way to proceed is to DROP DATABASE, CREATE a fresh empty database, and pg_restore into that. regards, tom lane --------------------------------- Do you Yahoo!? Next-gen email? Have it all with the all-new Yahoo! Mail Beta. --0-1830066886-1150678970=:69850 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Thanks Aaron

I am trying to do exactly the same thing. Now that my understanding of pg_restore is clearer. I was worried by my index key table was corrupted somehow and caused the error message.  This is the cause by my own misunderstanding.

CY

Aaron Bono <postgresql@aranya.com> wrote:
I agree.  When restoring a database from back up, I do a drop database and recreate it to make sure everything is properly intact (tables, columns, views, triggers, foreign keys, etc...).  We do this a lot for testing.  We backup the production database, copy to test server and do a restore on the test database.  It helps us test our code rollouts.

-Aaron

On 6/18/06, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Infor Gates <info_gates@yahoo.com> writes:
> I am having the impression that pg_restore would over-rides the "old"
> data with the current one. Is my thinking wrong?

Yeah.  By default, pg_restore will issue a CREATE TABLE (which of course
fails if the table already exists) followed by COPY (which just tries to
insert data in addition to what might be there already).

There's a command line option to ask pg_restore to try to DROP TABLE
before doing the CREATE TABLE.  By and large, though, that's a bad way
to proceed unless you are specifically trying to merge two databases.
The fast and easy way to proceed is to DROP DATABASE, CREATE a fresh
empty database, and pg_restore into that.

                        regards, tom lane


Do you Yahoo!?
Next-gen email? Have it all with the all-new Yahoo! Mail Beta. --0-1830066886-1150678970=:69850--