Re: Copying data from a table to another database

From: Shane Ambler <pgsql(at)Sheeky(dot)Biz>
To: Pedro Doria Meunier <pdoria(at)netmadeira(dot)com>
Cc: Postgresql Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Copying data from a table to another database
Date: 2008-05-25 19:51:58
Message-ID: 4839C35E.3060603@Sheeky.Biz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Pedro Doria Meunier wrote:
> Hi all,
>
> This is perhaps a very 'newbie' question but for the life of me, I can't
> see a way to do it without resorting to programming... (blush)

something like -

pg_dump --data-only --table=myoldhistorytable | psql -h x.x.x.x mynewdb

> The thing is:
> I have a table that acts as a historic for some devices activity.
> Now I've migrated the entire 'shebang' to another server and need to
> update the history table on the new server with data from the old server
> for every different record.

If I get that right the old server has some of the new data (or more
importantly - updates to rows that were transferred) since the transfer
started?

Your best bet would be to pg_dump the data then change the table name at
the start of the file to match a temp table name that can take the old
history and then insert/update from the temp table to the new server
history table.

> As the table on the new server grows exponentially (already nearing 1M
> records) I need to do this asap unless I want the entire thing to take
> forever... (sweat)
>
> Could someone please lend me a hand here?
>
> Already thankful for any insight,
>

--

Shane Ambler
pgSQL (at) Sheeky (dot) Biz

Get Sheeky @ http://Sheeky.Biz

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Shane Ambler 2008-05-25 20:01:08 Re: Optimzing Postgresql
Previous Message Reece Hart 2008-05-25 19:38:23 Re: Copying data from a table to another database