Oracle 建立数据库dblink 然后同步部分表内容的总结

同步处理部分数据


背景

  • 最近在项目上发现两个分库进行数据同步时部分内容同步存在问题.
  • 最简单的方法是导表,但是害怕有其他关联信息异常, 所以同事想到了dblink的方式.
  • 这里简单整理一下 同事用到的方法 作为总结 备忘.

建立数据库连接

create database  link test connect to yourname identified by "yourpassword"
using '(DESCRIPTION =(ADDRESS_LIST =
(ADDRESS =
(PROTOCOL = TCP)
(HOST = someip)
(PORT = 1521)))
(CONNECT_DATA =(SERVICE_NAME = servicename)))';

记性备份,以及添加未同步的数据

select * from sometable@fzzk where id not in(select id from sometable)
create table somtable_1206bak as select * from somtable
insert into sometable select * from sometable@fzzk where id not in(select id from sometable)

升级不一致的数据

merge into somtable a
using sometable@fzzk b
on (a.id=b.id)
when matched then
  update set a.treeinfo_path = b.treeinfo_path
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章