Oracle在执行从另一个模式读取的MV的快速刷新时失败。
SCHEMA_A包含源表
create table test_new_20230508 (pname varchar(100) PRIMARY KEY );
insert into TEST_NEW_20230508 (PNAME) values ('some name');
CREATE MATERIALIZED VIEW LOG ON TEST_NEW_20230508 WITH ROWID, PRIMARY KEY;
grant select on TEST_NEW_20230508 to SCHEMA_B;
commit;
在SCHEMA_B上,我们尝试
-- ok
CREATE MATERIALIZED VIEW TEST_NEW_20230508_MV AS select * from SCHEMA_A.TEST_NEW_20230508;
-- ok
SELECT * FROM TEST_NEW_20230508_MV;
-- fails
BEGIN
DBMS_MVIEW.REFRESH('TEST_NEW_20230508_MV', 'F');
END;
误差是
[2023-05-08 16:09:25] [72000][12018]
[2023-05-08 16:09:25] ORA-12018: following error encountered during code generation for "SCHEMA_B"."TEST_NEW_20230508_MV"
[2023-05-08 16:09:25] ORA-06512: at "SYS.DBMS_SNAPSHOT_KKXRCA", line 3020
[2023-05-08 16:09:25] ORA-06512: at "SYS.DBMS_SNAPSHOT_KKXRCA", line 2432
[2023-05-08 16:09:25] ORA-00942: table or view does not exist
[2023-05-08 16:09:25] ORA-06512: at "SYS.DBMS_SNAPSHOT_KKXRCA", line 88
[2023-05-08 16:09:25] ORA-06512: at "SYS.DBMS_SNAPSHOT_KKXRCA", line 253
[2023-05-08 16:09:25] ORA-06512: at "SYS.DBMS_SNAPSHOT_KKXRCA", line 2413
[2023-05-08 16:09:25] ORA-06512: at "SYS.DBMS_SNAPSHOT_KKXRCA", line 2976
[2023-05-08 16:09:25] ORA-06512: at "SYS.DBMS_SNAPSHOT_KKXRCA", line 3263
[2023-05-08 16:09:25] ORA-06512: at "SYS.DBMS_SNAPSHOT_KKXRCA", line 3295
[2023-05-08 16:09:25] ORA-06512: at "SYS.DBMS_SNAPSHOT", line 16
[2023-05-08 16:09:25] ORA-06512: at line 2
[2023-05-08 16:09:25] Position: 0
db版本为
select BANNER_FULL from V$VERSION;
Oracle Database 19 c企业版19.0.0.0.0 -生产版本19.17.0.0.0
注1️
如果创建的mv日志没有主键,则上述方法有效
CREATE MATERIALIZED VIEW LOG ON TEST_NEW_20230508 WITH ROWID;
如果不是FAST,则进行刷新
BEGIN
DBMS_MVIEW.REFRESH('TEST_NEW_20230508_MV');
END;
注2️
如果MV位于相同的源方案SCHEMA_A而不是SCHEMA_B中,则FAST刷新有效
根据ORA-00942: table or view does not exist
,我猜测当SCHEMA_B试图访问链接到主键的MV日志上所需的一些数据时,可能出现了问题。
跨架构运行快速刷新需要任何其他赠款吗?
2条答案
按热度按时间5m1hhzi41#
为了快速刷新,除了在表TEST_NEW_20230508上进行选择外,还必须在MV日志上将select授予
SCHEMA_B
。MV日志本身就是一个表格。jw5wzhpr2#
通过在日志表上授予选择权限解决了问题
我希望这将帮助其他人。错误消息确实不透明。