oracle数据库数据的同步操作

来源:互联网 发布:没有激素的护肤品知乎 编辑:程序博客网 时间:2024/05/20 16:12

(1)在源库中建目标库(fantastic)的dblink,使可以在源库中查看目标库的表

drop database link link_fantastic;    --删除linkcreate database link link_fantastic connect to fantastic identified by "fantastic"   using '(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST =60.30.69.73)(PORT = 31521)))(CONNECT_DATA =(SERVICE_NAME =orcl)))';       --新建linkselect * from dba_db_links;     --查看所有linkselect * from users@link_fantastic;     --通过link查看远程库表


(2)在源库中进行merge操作

merge into users@link_fantastic b using users c on (b.username=c.username)  when matched then update set b.password=c.password  when not matched then                                insert values (c.username, c.password, null);    --把源库中users表的数据并到fantastic中,users表commit;      --记得merge后必须commit,否则更改未能提交

注:都是在源库中操作,操作后源库中表数据不变。

原创粉丝点击