收藏 分享(赏)

oracle数据库同步dblink.doc

上传人:精品资料 文档编号:10478132 上传时间:2019-11-21 格式:DOC 页数:5 大小:14.21KB
下载 相关 举报
oracle数据库同步dblink.doc_第1页
第1页 / 共5页
oracle数据库同步dblink.doc_第2页
第2页 / 共5页
oracle数据库同步dblink.doc_第3页
第3页 / 共5页
oracle数据库同步dblink.doc_第4页
第4页 / 共5页
oracle数据库同步dblink.doc_第5页
第5页 / 共5页
亲,该文档总共5页,全部预览完了,如果喜欢就下载吧!
资源描述

1、-下面两种建立 dblink 方法人选一种-远程连接数据流-1、 -目的数据库 创建 dblink -CREATE PUBLIC DATABASE LINK 数据库链名称 CONNECT TO 用户名 identified by 密码 using (DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = 远程服务器 IP)(PORT = 端口)(CONNECT_DATA =(service_name=连接到数据库服务名 );例:CREATE PUBLIC DATABASE LINK dblink_orcl_bql_scan

2、CONNECT TO emuser_bql identified by empsw_bql using (DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = 172.17.193.161)(PORT = 1521)(CONNECT_DATA =(service_name=orcl);-2、 -目的数据库 创建 dblinkdrop public database link dblink_orcl_bql_scan;Create public DATABASE LINK dblink_orcl_bql_scan CONNE

3、CT TO emuser_bql IDENTIFIED BY emuser_bql USING orcl;-在 源数据库上,创建要同步表的快照日志Create snapshot log on basedata_leechdom;Create snapshot log on basedata_therapyitem;-第二步-在目的数据库 -建立快照-Create snapshot SNM_LEECHDOMID as select * from basedata_leechdomdblink_orcl_bql_scan;Create snapshot SNM_ITEMID as select *

4、 from basedata_therapyitemdblink_orcl_bql_scan;Alter snapshot SNM_LEECHDOMID refresh fast Start with sysdate next sysdate with primary key;Alter snapshot SNM_ITEMID refresh fast Start with sysdate next sysdate with primary key;-在目的数据库建立触发器 -注:单个执行-create or replace trigger sn_delete after delete on

5、SNM_LEECHDOMID for each row begin delete from basedata_leechdom where LEECHDOMID=:old.leechdomid;end;-create or replace trigger sn_insertafter insert on SNM_LEECHDOMID for each row begin insert into basedata_leechdom(leechdomid, leechdomcode, leechdomname, feesort, feesortname, paymethod, paymethodn

6、ame, type, scope, memorycode, isleechdom, parentid, ismxb, isjsb, standard)values(:new.leechdomid,:new.leechdomcode,:new.leechdomname,:new.feesort,:new.feesortname,:new.paymethod,:new.paymethodname,:new.type,:new.scope,:new.memorycode,:new.isleechdom,:new.parentid,:new.ismxb,:new.isjsb,:new.standard

7、);end;-create or replace trigger sn_update after update on SNM_LEECHDOMID for each row begin update basedata_leechdom set leechdomcode=:new.leechdomcode,leechdomname =:new.leechdomname,feesort=:new.feesort,feesortname=:new.feesortname,paymethod=:new.paymethod,paymethodname=:new.paymethodname,type=:n

8、ew.type,scope=:new.scope,memorycode=:new.memorycode,isleechdom=:new.isleechdom,parentid=:new.parentid,ismxb=:new.ismxb,isjsb=:new.isjsb,standard=:new.standardwhere LEECHDOMID=:old.leechdomid;end;-create or replace trigger th_deleteafter delete on SNM_ITEMID for each row begin delete from basedata_th

9、erapyitemwhere itemid = :old.itemid;end;-create or replace trigger th_insert after insert on SNM_ITEMID for each row begin insert into basedata_therapyitem(itemid, itemcode, name,unit, feesort,feesortname, paymethod,paymethodname, exceptioncont,description,meaning, itemsort,isitem, parentid,memoryco

10、de)values(:new.ITEMID,:new.itemcode,:new.name,:new.unit,:new.feesort,:new.feesortname,:new.paymethod,:new.paymethodname,:new.exceptioncont,:new.description,:new.meaning,:new.itemsort,:new.isitem,:new.parentid,:new.memorycode);end;-create or replace trigger th_updateafter update on SNM_ITEMID for eac

11、h row begin update basedata_therapyitemset itemid = :new.itemid,itemcode = :new.itemcode,name = :new.name,unit = :new.unit,feesort = :new.feesort,feesortname = :new.feesortname,paymethod = :new.paymethod,paymethodname = :new.paymethodname,exceptioncont = :new.exceptioncont,description = :new.descrip

12、tion,meaning = :new.meaning,itemsort = :new.itemsort,isitem = :new.isitem,parentid = :new.parentid,memorycode = :new.memorycodewhere itemid = :old.itemid;end;-测试-查看快照 -SNM_LEECHDOMID 和 SNM_ITEMID 运行状况-在目的数据库中执行 -SELECT NAME,LAST_REFRESH FROM ALL_SNAPSHOT_REFRESH_TIMES;select last_date,next_date,what from user_jobs order by next_date;-测试查询 源数据库数据-在目的数据库中执行-select * from basedata_leechdomdblink_orcl_bql_scan;

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 企业管理 > 管理学资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报