1.创建dblink
create public database link xirEvalDBlink connect to "XIR_TRD" identified by "xpar" USING ' (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 191.168.0.11)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl) ) ) ';
2.创建物化视图
(全量刷新)
CREATE MATERIALIZED VIEW mv_sync_eval REFRESH COMPLETE AS SELECT * FROM TCB_BOND_EVAL@xirEvalDBlink;
(增量刷新)
实体化视图日志是在创建增量物化视图时必需的,因为它们用于跟踪源表中的更改并更新物化视图。如果表TCB_BOND_EVAL没有实体化视图日志,则无法创建增量物化视图。
要解决此问题,您需要在表TCB_BOND_EVAL上启用实体化视图日志。可以使用以下命令来执行此操作:
ALTER TABLE TCB_BOND_EVAL ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS;
此命令将为表B启用实体化视图日志,并允许您创建增量物化视图。
请注意,启用实体化视图日志可能会对系统性能产生一定的影响。因此,在为表启用实体化视图日志之前,请确保已充分评估其影响。
CREATE MATERIALIZED VIEW mv_sync_B REFRESH FAST ON DEMAND AS SELECT * FROM TCB_BOND_EVAL@xirEvalDBlink;
3.创建定时任务作业
BEGIN DBMS_SCHEDULER.create_job ( job_name => 'sync_xir_to_xspeval', job_type => 'PLSQL_BLOCK', job_action => 'BEGIN DBMS_MVIEW.REFRESH(''mv_sync_eval'', ''C''); INSERT INTO TCB_BOND_EVAL SELECT * FROM mv_sync_eval; END;', start_date => SYSTIMESTAMP, repeat_interval => 'FREQ=DAILY; BYHOUR=1', --每天1点执行 enabled => TRUE); END;
标签:实体化,物化,dblink,视图,EVAL,ORACLE,TCB,BOND From: https://www.cnblogs.com/zhangqb/p/17411673.html