试着执行快速刷新:
SQL> exec dbms_mview.refresh('SERVICE_ITEMS','F');
BEGIN dbms_mview.refresh('SERVICE_ITEMS','F'); END;
*
第 1 行出现错误:
ORA-23413: table "SGREPORTS"."SERVICE_ITEMS" does not have a materialized view log
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2255
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2461
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2430
ORA-06512: at line 1
试着完全刷新:
SQL> exec dbms_mview.refresh('SERVICE_ITEMS','C');
PL/SQL 过程已成功完成。
在主上建立物化日志:
先看一下表的变化频率!然后建立日志!
SQL> select count(*) from SERVICE_ITEMS;
COUNT(*)
----------
90908
SQL> /
COUNT(*)
----------
90908
变化不大,应该使用快速刷新!
SQL> create materialized view log on SERVICE_ITEMS;
Materialized view log created.
再试!
SQL> exec dbms_mview.refresh('SERVICE_ITEMS','F');
BEGIN dbms_mview.refresh('SERVICE_ITEMS','F'); END;
*
第 1 行出现错误:
ORA-12034: materialized view log on "SGREPORTS"."SERVICE_ITEMS" younger than last refresh
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2255
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2461
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2430
ORA-06512: at line 1
这个错误可以使用完全刷新来修正!
SQL> exec dbms_mview.refresh('SERVICE_ITEMS','C');
PL/SQL 过程已成功完成。
再试快速刷新!
SQL> exec dbms_mview.refresh('SERVICE_ITEMS','F');
BEGIN dbms_mview.refresh('SERVICE_ITEMS','F'); END;
*
第 1 行出现错误:
ORA-12018: following error encountered during code generation for "SGREPORTS"."SERVICE_ITEMS"
ORA-00942: table or view does not exist
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2255
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2461
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2430
ORA-06512: at line 1
SQL> commit;
提交完成。
这个错误是由于没有在主站点上找到物化日志!
原因是刷新的用户没有访问物化日志的权限,在主站上做相应授权:
SQL> GRANT SELECT ON MLOG$_SERVICE_ITEMS to smcrep;
Grant succeeded.
再试快速刷新!
SQL> exec dbms_mview.refresh('SERVICE_ITEMS','F');
PL/SQL 过程已成功完成。
SQL>