我有一个带有多个物化视图的Oracle数据库11g,我想每晚刷新一次。我确实创建了一个在Oracle中安排的过程。
在该过程中,我使用以下语法刷新MV:
BEGIN
DBMS_MVIEW.REFRESH(' MV_1','C', atomic_refresh=>false);
END;
MV_1如下所示:
SELECT
/*+ NO_PARALLEL(adres@db2) */
a.n a_nr ,
c.c_nr ,
a.i id ,
b.name ,
FROM TABLE(pck_1.fnc_1) a
JOIN b b
ON a.i = b.id
JOIN adres@db2 c
ON a.n = c.nr;
请注意表ADRES和TABLEtype I的数据库链接从函数FNC_1
查询运行正常,大约需要5分钟。 运行SELECT TABLE(pck_1.fnc_1)FROM DUAL也需要大约5分钟,并返回一个包含两列(I和N)的表。
但是当我执行刷新MV的过程时,我得到了一个ora-12840错误:
Error starting at line 1 in command:
BEGIN
DBMS_MVIEW.REFRESH(' MV_1','C', atomic_refresh=>false);
END;
Error report:
ORA-12008: Fout in pad voor vernieuwen van snapshot.
ORA-12840: Kan externe tabel niet benaderen na een parallelle transactie of een transactie voor direct invoegen.
ORA-06512: in "SYS.DBMS_SNAPSHOT", regel 2566
ORA-06512: in "SYS.DBMS_SNAPSHOT", regel 2779
ORA-06512: in "SYS.DBMS_SNAPSHOT", regel 2748
ORA-06512: in regel 2
12008. 00000 - "error in materialized view refresh path"
*Cause: Table SNAP$_<mview_name> reads rows from the view
MVIEW$_<mview_name>, which is a view on the master table
(the master may be at a remote site). Any
error in this path will cause this error at refresh time.
For fast refreshes, the table <master_owner>.MLOG$_<master>
is also referenced.
*Action: Examine the other messages on the stack to find the problem.
See if the objects SNAP$_<mview_name>, MVIEW$_<mview_name>,
<mowner>.<master>@<dblink>, <mowner>.MLOG$_<master>@<dblink>
still exist.
当我将atomic_refresh过程的值更改为true时,该过程成功完成。
所以这是我的问题:
我确实给了atomic_refresh参数FALSE的值来强制截断MV,因此MV的刷新速度更快。作为一个副作用,它会创建多个会话(并行),这会导致我的SQL错误。添加参数PARALLILISM =&gt; 0没有给出任何结果。
是否可以尽快完全刷新物化视图,我不担心在一个会话中撤消数据。
这就是Oracle所说的atomic_refresh:http://docs.oracle.com/cd/E11882_01/appdev.112/e40758/d_mview.htm#ARPLS67204