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;
/

上一篇:jQuery DOM


下一篇:Oracle数据库入门——物化视图语法