On a website I have some scripts which work on a temporary database. Before the scripts are starting I drop and recreate the temporary database from the production database. On the end of the process I would like to update the production database with the results of these scripts from the temporary database, but with keeping the modifications which happened meanwhile the scripts was run (several hour).
I know the replace into is not implemented in the postgreSQL, but I found this solution which will work for me: How to UPSERT (MERGE, INSERT ... ON DUPLICATE UPDATE) in PostgreSQL?
My problem is that for this solution I have to link the two database together, and as far as I found this also not implemented in the postgreSQL so I have to copy the tables from the temporary database to the live database but I have to change the name of the tables meanwhile to prevent to duplicate values or prevent unwanted changes. I have approximately 30 table but only around half of them are modified by the scripts, so it would be great if I can limit the tables to work on. As far as I found the only method for this to pg_dump from the temporary database into a file and insert them into the production table, but it's not too elegant solution and it would maybe too slow as well.
How can I solve this problem on an effective way?
I have postgreSQL 8.3 on Linux (Ubuntu) and root access.