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!