Why does a ORA-12054 error occur when creating this simple materialized view example?(为什么在创建这个简单的物化视图示例时会出现 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 错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为什么在创建这个简单的物化视图示例时会出现 ORA-12054 错误?


- 在SQL中,如何为每个组选择前2行 2021-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 更改自动增量起始编号? 2021-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- SQL 临时表问题 2022-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01