Postgresql dblink

Discussion of open issues, suggestions and bugs regarding database management and development tools for PostgreSQL
Post Reply
wusir01
Posts: 6
Joined: Tue 10 Dec 2013 10:29

Postgresql dblink

Post by wusir01 » Tue 10 Dec 2013 10:43

Hi,
I've a problem with postgresql dblink. I'm working on database synchronization. I have one master database1 hosted on host1 and a slave database2 hosted on host2. the 2 databases have not the same tables columns (differences between tables data model). on each changes operated on database1 (hoste1) I want to replicate it on a specific column and specific table on database2 (host2) using dblink. can someone help me please ??

alexa

Re: Postgresql dblink

Post by alexa » Tue 10 Dec 2013 10:57

You have to map the columns manually. Please refer to the 'How To: Map Columns' and 'How To: Map Tables and Views' topics in the product's Help documentation for details.

wusir01
Posts: 6
Joined: Tue 10 Dec 2013 10:29

Re: Postgresql dblink

Post by wusir01 » Tue 10 Dec 2013 11:11

select dblink_connect_u('conn104', 'hostaddr=192.168.1.104 port=5432 dbname=db104 user=postgres password=postgres');

select dblink_connect_u('conn105', 'hostaddr=192.168.1.105 port=5432 dbname=db105 user=postgres password=postgres');


select dblink_exec('conn105',
'insert into db105.table1(col1, col2) select * from dblink('conn104', 'select * from db104.table2')
return (id int, colx varchar);');

alexa

Re: Postgresql dblink

Post by alexa » Wed 11 Dec 2013 15:00

Please try specifying the queries in the 'Custom Queries Mapping' dialog box. dbForge may compare them, however, there is no guarantee that it can synchronize them. Please see the 'Custom Queries Mapping Dialog Box' topic in the product's Help documentation.

Also, you could try to explicitly connect to the Source and Target databases without using dblinks and perform comparison/synchronization.

Post Reply