为什么在创建这个简单的物化视图示例时会出现 ORA-12054 错误?

Why does a ORA-12054 error occur when creating this simple materialized view example?(为什么在创建这个简单的物化视图示例时会出现 ORA-12054 错误?)
本文介绍了为什么在创建这个简单的物化视图示例时会出现 ORA-12054 错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ALTER TABLE RECORDINGS ADD PRIMARY KEY (ID);

CREATE MATERIALIZED VIEW LOG ON RECORDINGS TABLESPACE USERS NOLOGGING;

DROP MATERIALIZED VIEW REC_SEARCH_TEST;
CREATE MATERIALIZED VIEW REC_SEARCH_TEST
REFRESH COMPLETE ON COMMIT
AS (
    SELECT DISTINCT ID, TITLE FROM RECORDINGS
);


ORA-12054: cannot set the ON COMMIT refresh attribute for the materialized view

无法理解这里有什么问题,我知道如果我去掉 DISTINCT 子句它可以工作,但是如果我指定了必需的REFRESH COMPLETE ON COMMIT",为什么我不能使用DISTINCT".

Cannot understand what is wrong here, I know that if I take out the DISTINCT clause it works, but why can I not use 'DISTINCT' if I specify 'REFRESH COMPLETE ON COMMIT' which is required.

如果我按需使用 DISTINCT 和 REFRESH 没有问题,但这些不是要求.

If I use DISTINCT and REFRESH on demand there is no problem, but these are not the requirements.

推荐答案

似乎通过添加 DISTINCT,您使视图的底层 SQL 不符合快速刷新的条件,因此无法与 ON COMMIT (即使您指定刷新完成而不是快速刷新).来自 Oracle 文档:

Seems like with the addition of the DISTINCT, you've made your view's underlying SQL ineligible for fast refresh, and therefore not able to be used with ON COMMIT (even tho you specify refresh complete instead of refresh fast). From Oracle docs:

两种刷新执行模式是ON COMMIT 和ON DEMAND.依赖在您创建的物化视图上,某些选项可能不可用的.表 8-4 描述了刷新模式.

The two refresh execution modes are ON COMMIT and ON DEMAND. Depending on the materialized view you create, some of the options may not be available. Table 8-4 describes the refresh modes.

表 8-4 刷新模式

提交

当一个事务修改了其中之一时自动发生刷新物化视图的明细表提交.这个可以指定只要物化视图可以快速刷新(换句话说,不复杂).使用此模式需要 ON COMMIT 权限.

Refresh occurs automatically when a transaction that modified one of the materialized view's detail tables commits. This can be specified as long as the materialized view is fast refreshable (in other words, not complex). The ON COMMIT privilege is necessary to use this mode.

按需

当用户手动执行可用的其中之一时会发生刷新DBMS_MVIEW 包 (REFRESH,REFRESH_ALL_MVIEWS,REFRESH_DEPENDENT).

Refresh occurs when a user manually executes one of the available refresh procedures contained in the DBMS_MVIEW package (REFRESH, REFRESH_ALL_MVIEWS, REFRESH_DEPENDENT).

同一个文档链接也有快速刷新的限制列表.

The same document link has a list of restrictions for fast refresh as well.

这篇关于为什么在创建这个简单的物化视图示例时会出现 ORA-12054 错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

SQL to Generate Periodic Snapshots from Transactions Table(用于从事务表生成定期快照的SQL)
MyBatis support for multiple databases(MyBatis支持多个数据库)
Oracle 12c SQL: Missing column Headers in result(Oracle 12c SQL:结果中缺少列标题)
SQL query to find the number of customers who shopped for 3 consecutive days in month of January 2020(查询2020年1月连续购物3天的客户数量)
How to get top 10 data weekly (This week, Previous week, Last month, 2 months ago, 3 month ago)(如何每周获取前十大数据(本周、前一周、上个月、2个月前、3个月前))
Select the latest record for an Id per day - Oracle pl sql(选择每天ID的最新记录-Oracle pl SQL)