Re: Getting tables from one DB to another

From: Aarni <aarni(at)kymi(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Cc: JORGE MALDONADO <jorgemal1960(at)gmail(dot)com>
Subject: Re: Getting tables from one DB to another
Date: 2010-12-15 10:21:50
Message-ID: 201012151221.50192.aarni@kymi.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Wednesday 15 December 2010 01:07:33 JORGE MALDONADO wrote:
> We actually have an application with its database working and we are
> developing a new version of such an application based on the same database
> but with minor changes in a few tables. When finished, we want to get the
> data in the actual DB to the new one but we see a liitle problem. Each
> table has a serial field which works as a primary key and we would like to
> keep these fields with their original values in the new tables. I suppose
> I cannot use pg_restore from a backup because of the difference among some
> old tables and some new ones; maybe one way could be to write an
> application that reads each record from the old table and inserts it to
> the new one but in this case the serial field could be different from the
> original. How can I achieve this goal?
>
> Respectfully,
> Jorge Maldonado
>

Hi Jorge,

You could you use eg. (Pg 8.4)

SELECT last_value, is_called FROM table_field_id_seq;

to see what is the last value in the old db and if it is called and then

SELECT pg_catalog.setval ('table_field_id_seq', 1234, true);

to set that serial in the new db.

BR,

Aarni

--
Aarni Ruuhimäki
--------------
This is a bug-free broadcast from Ubuntu 9.10
Karmic Koala Linux System

PROUD TO BE 100% Microsoft FREE!

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Dara Olson 2010-12-15 22:02:37 create function and trigger to update column on table update
Previous Message Magnus Hagander 2010-12-15 06:46:24 Re: Need static version of libpq library