oracle 11g 使用物化視圖遠程增量刷新數據


① 源數據庫建立物化視圖日志

drop MATERIALIZED VIEW LOG ON ORG_BASEINFO
/

CREATE MATERIALIZED VIEW LOG ON ORG_BASEINFO
with rowid,PRIMARY KEY
including new values
/
drop MATERIALIZED VIEW LOG ON ORG_MOREINFO
/
CREATE MATERIALIZED VIEW LOG ON ORG_MOREINFO
with rowid,PRIMARY KEY
including new values
/

② 在目標庫上建立數據庫連接

Create Database Link   DBLINK_NT_EPORT_RIGHTS

③ 在目標庫上建立物化視圖,數據來源於遠程數據表

DROP materialized view MV_ORG_BASEINFO
/
create materialized view MV_ORG_BASEINFO refresh fast on DEMAND as select id,
org_name_cn,
org_name_scn,
org_code,
bus_lic_code,
tax_code,
address_cn,
org_property,
org_type,
legal_name,
legal_phone,
cert_type,
cert_no,
sheng,
shi,
quxian,
area_code,
logo,
order_num,
reg_type,
check_state,
check_adv,
check_succ_time,
remark,
create_user,
create_user_id,
create_date,
update_user,
update_user_id,
update_date,
area_name,
state,
fjtd_type,
org_star,
copy_type,
settle_pattern,
org_code1,
decl_flag,
decl_pass,
sname,
complete_state,
orggrade,
inspectionuser,
inspectionpassword,
inspectionchannel,
corp_code
from ORG_BASEINFO@DBLINK_NT_EPORT_RIGHTS
/
BEGIN dbms_mview.refresh('MV_ORG_BASEINFO','F');END;
/

DROP materialized view MV_ORG_MOREINFO
/
create materialized view MV_ORG_MOREINFO refresh fast on DEMAND
as
select org_id,
org_name_en,
ie_enter_code,
ic_code,
zip_code,
address_en,
org_url,
bank,
bank_acount,
reg_mon,
custom_no,
inspect_no,
custom_type,
custom_code,
custom_limittime,
business_scope,
ic_code_no
from ORG_MOREINFO@DBLINK_NT_EPORT_RIGHTS
/
BEGIN dbms_mview.refresh('MV_ORG_MOREINFO','F');END;
/

④ 在目標庫上創建計划任務,定時增量刷新物化視圖

declare
job_id number;
begin
DBMS_JOB.submit(job =>job_id,what => 'begin dbms_mview.refresh(''MV_ORG_BASEINFO'',''F'');dbms_mview.refresh(''MV_ORG_MOREINFO'',''F'');end;',next_date => sysdate,interval => 'sysdate + 10.0/(60*60*24)');
COMMIT;
end;
/

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM