Hi Chris or anyone who can help


When I try this just below, it complains about foo (new table created in
db2) , saying *ERROR: schema foo does not exist*. I got stuck on this error
for a while now but still trying to see why but still no luck so far. If
you have something please help





begin;



update foo

set br_desc = bar.br_desc

, br_active = bar.br_active

(rest of columns)

where foo.br_cde = bar.br_cde;















*From:* Khangelani Gama [mailto:kg...@argility.com <kg...@argility.com>]
*Sent:* Friday, March 28, 2014 7:52 AM
*To:* 'ch...@chriscurvey.com'; 'pgsql'
*Subject:* RE: [GENERAL] Synchronizing a table that is two different
databases : Need to dump a table a insert from db1 and change the insert
statements into UPDATE statements



Thank you very much, I will try option 2 because option 1 will give me FK
constrains. These two databases are not exactly similar, but few tables on
each of these Databases needs to be exactly the same, in this case db1 is
the reliable one,  hence that's why I need to update db2 with what it's in
db1.



*From:* ccur...@gmail.com [mailto:ccur...@gmail.com <ccur...@gmail.com>] *On
Behalf Of *Chris Curvey
*Sent:* Thursday, March 27, 2014 3:08 PM
*To:* Khangelani Gama; pgsql
*Subject:* Re: [GENERAL] Synchronizing a table that is two different
databases : Need to dump a table a insert from db1 and change the insert
statements into UPDATE statement



(For clarity, I'm going to call the table in question "foo".)



Option 1:  If you just want to do a full copy of db1.foo to db2.foo, then
do that. Dump foo from db1, truncate foo in db2 and load db2.foo from the
dump.  But you might not be able to do that (foreign keys and such).  In
that case..



Option 2:  Dump the table from db1, then load it into a table with a
different name ("bar") in db2.  Then you can do this:



begin;



update foo

set br_desc = bar.br_desc

, br_active = bar.br_active

(rest of columns)

where foo.br_cde = bar.br_cde;



insert into foo (br_cde, br_desc, br_active, ...)

select br_cde, br_desc, br_active, ....

from bar

where not exists

(  select *

   from foo

   where foo.br_cde = bar.br_cde);



commit;



CONFIDENTIALITY NOTICE
The contents of and attachments to this e-mail are intended for the addressee 
only, and may contain the confidential
information of Argility (Proprietary) Limited and/or its subsidiaries. Any 
review, use or dissemination thereof by anyone
other than the intended addressee is prohibited.If you are not the intended 
addressee please notify the writer immediately
and destroy the e-mail. Argility (Proprietary) Limited and its subsidiaries 
distance themselves from and accept no liability
for unauthorised use of their e-mail facilities or e-mails sent other than 
strictly for business purposes.

Reply via email to