Re: copy table from one database to another

From: John McKown <joarmc(at)swbell(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: copy table from one database to another
Date: 2000-09-20 23:16:37
Message-ID: Pine.LNX.4.21.0009201813350.30269-100000@linux2.johnmckown.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, 20 Sep 2000, Vince Vielhaber wrote:

> On Wed, 20 Sep 2000, John McKown wrote:
>
> What version of PostgreSQL are you using? I move tables around all the
> time and don't need to edit. Instead of the \i, try this:
>
> pg_dump -t table olddb > old.info
>
> psql newdb < old.info

I'm running PostgreSQL 7.0.2. The reason that I had to edit the pg_dump
output was because I needed to rename the table. That's because I did not
think ahead and I had an empty table in the newdb with the same name as
the one in the olddb. I did not want to replace the table defination. But
now that you mention it, I guess that I could have done an ALTER TABLE
... RENAME TO ... in olddb before doing the pg_dump.

Thanks for the thoughts!
John

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Edward Q. Bridges 2000-09-20 23:27:40 Re: perl Pg module and result status
Previous Message Vince Vielhaber 2000-09-20 23:09:51 Re: Public Database of zip code information