ORA-12054: 无法为实体化视图设置 ON COMMIT 刷新属性 物化视图与一般视图有何区别

Oracle\u7269\u5316\u89c6\u56fe\u5237\u65b0\u65b9\u5f0fon commit \u95ee\u9898

\u521a\u770b\u4e86\u4e00\u4e0b10g\u7684\u5feb\u901f\u5237\u65b0\u9650\u5236\u6761\u4ef6\uff0c\u660e\u786e\u8bf4\u660e\u4e86\u5305\u542b\u5206\u6790\u51fd\u6570\u7684\u7269\u5316\u89c6\u56fe\u662f\u65e0\u6cd5\u5feb\u901f\u5237\u65b0\u7684\uff1a

General Restrictions on Fast Refresh
The defining query of the materialized view is restricted as follows:

The materialized view must not contain references to non-repeating expressions like SYSDATE and ROWNUM.

The materialized view must not contain references to RAW or LONG RAW data types.

It cannot contain a SELECT list subquery.

It cannot contain analytical functions (for example, RANK) in the SELECT clause.

It cannot contain a MODEL clause.

It cannot contain a HAVING clause with a subquery.

It cannot contain nested queries that have ANY, ALL, or NOT EXISTS.

It cannot contain a [START WITH \u2026] CONNECT BY clause.

It cannot contain multiple detail tables at different sites.

On-commit materialized view cannot have remote detail tables.

Nested materialized views must have a join or aggregate.

\u7269\u5316\u89c6\u56fe\u662f\u4e00\u79cd\u7279\u6b8a\u7684\u7269\u7406\u8868\uff0c
\u201c
\u7269\u5316
\u201d(Materialized)
\u89c6\u56fe\u662f\u76f8\u5bf9\u666e\u901a\u89c6\u56fe\u800c\u8a00\u7684\u3002\u666e\u901a
\u89c6\u56fe\u662f\u865a\u62df\u8868\uff0c\u5e94\u7528\u7684\u5c40\u9650\u6027\u5927\uff0c\u4efb\u4f55\u5bf9\u89c6\u56fe\u7684\u67e5\u8be2\uff0c
Oracle
\u90fd\u5b9e\u9645\u4e0a\u8f6c\u6362\u4e3a\u89c6\u56fe
SQL
\u8bed
\u53e5\u7684\u67e5\u8be2\u3002\u8fd9\u6837\u5bf9\u6574\u4f53\u67e5\u8be2\u6027\u80fd\u7684\u63d0\u9ad8\uff0c\u5e76\u6ca1\u6709\u5b9e\u8d28\u4e0a\u7684\u597d\u5904\u3002


1
\u3001\u7269\u5316\u89c6\u56fe\u7684\u7c7b\u578b\uff1a
ON DEMAND
\u3001
ON COMMIT


\u4e8c\u8005\u7684\u533a\u522b\u5728\u4e8e\u5237\u65b0\u65b9\u6cd5\u7684\u4e0d\u540c\uff0c
ON DEMAND
\u987e\u540d\u601d\u4e49\uff0c\u4ec5\u5728\u8be5\u7269\u5316\u89c6\u56fe
\u201c
\u9700\u8981
\u201d
\u88ab\u5237
\u65b0\u4e86\uff0c\u624d\u8fdb\u884c\u5237\u65b0
(REFRESH)
\uff0c\u5373\u66f4\u65b0\u7269\u5316\u89c6\u56fe\uff0c\u4ee5\u4fdd\u8bc1\u548c\u57fa\u8868\u6570\u636e\u7684\u4e00\u81f4\u6027\uff1b\u800c
ON
COMMIT
\u662f\u8bf4\uff0c\u4e00\u65e6\u57fa\u8868\u6709\u4e86
COMMIT
\uff0c\u5373\u4e8b\u52a1\u63d0\u4ea4\uff0c\u5219\u7acb\u523b\u5237\u65b0\uff0c\u7acb\u523b\u66f4\u65b0\u7269\u5316\u89c6\u56fe\uff0c
\u4f7f\u5f97\u6570\u636e\u548c\u57fa\u8868\u4e00\u81f4\u3002


2
\u3001
ON DEMAND
\u7269\u5316\u89c6\u56fe



\u7269\u5316\u89c6\u56fe\u7684\u521b\u5efa\u672c\u8eab\u662f\u5f88\u590d\u6742\u548c\u9700\u8981\u4f18\u5316\u53c2\u6570\u8bbe\u7f6e\u7684\uff0c\u7279\u522b\u662f\u9488\u5bf9\u5927\u578b\u751f\u4ea7\u6570\u636e\u5e93\u7cfb\u7edf
\u800c\u8a00\u3002\u4f46
Oracle
\u5141\u8bb8\u4ee5\u8fd9\u79cd\u6700\u7b80\u5355\u7684\uff0c\u7c7b\u4f3c\u4e8e\u666e\u901a\u89c6\u56fe\u7684\u65b9\u5f0f\u6765\u505a\uff0c\u6240\u4ee5\u4e0d\u53ef\u907f\u514d\u7684\u4f1a\u6d89
\u53ca\u5230\u9ed8\u8ba4\u503c\u95ee\u9898\u3002\u4e5f\u5c31\u662f\u8bf4
Oracle
\u7ed9\u7269\u5316\u89c6\u56fe\u7684\u91cd\u8981\u5b9a\u4e49\u53c2\u6570\u7684\u9ed8\u8ba4\u503c\u5904\u7406\u662f\u6211\u4eec\u9700\u8981\u7279
\u522b\u6ce8\u610f\u7684\u3002



\u7269\u5316\u89c6\u56fe\u7684\u7279\u70b9\uff1a


(1)
\u7269\u5316\u89c6\u56fe\u5728\u67d0\u79cd\u610f\u4e49\u4e0a\u8bf4\u5c31\u662f\u4e00\u4e2a\u7269\u7406\u8868
(
\u800c\u4e14\u4e0d\u4ec5\u4ec5\u662f\u4e00\u4e2a\u7269\u7406\u8868
)
\uff0c
\u8fd9\u901a\u8fc7\u5176\u53ef\u4ee5
\u88ab
user_tables
\u67e5\u8be2\u51fa\u6765\uff0c\u800c\u5f97\u5230\u4f50\u8bc1\uff1b


(2)
\u7269\u5316\u89c6\u56fe\u4e5f\u662f\u4e00\u79cd\u6bb5
(segment)
\uff0c\u6240\u4ee5\u5176\u6709\u81ea\u5df1\u7684\u7269\u7406\u5b58\u50a8\u5c5e\u6027\uff1b


(3)
\u7269\u5316\u89c6\u56fe\u4f1a\u5360\u7528\u6570\u636e\u5e93\u78c1\u76d8\u7a7a\u95f4\uff0c
\u8fd9\u70b9\u4ece
user_segment
\u7684\u67e5\u8be2\u7ed3\u679c\uff0c
\u53ef\u4ee5\u5f97\u5230\u4f50\u8bc1\uff1b



\u521b\u5efa\u8bed\u53e5\uff1a
create materialized view mv_name as select * from table_name


\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c
\u5982\u679c\u6ca1\u6307\u5b9a\u5237\u65b0\u65b9\u6cd5\u548c\u5237\u65b0\u6a21\u5f0f\uff0c
\u5219
Oracle
\u9ed8\u8ba4\u4e3a
FORCE
\u548c
DEMAND
\u3002




\u7269\u5316\u89c6\u56fe\u7684\u6570\u636e\u600e\u4e48\u968f\u7740\u57fa\u8868\u800c\u66f4\u65b0\uff1f


Oracle
\u63d0\u4f9b\u4e86\u4e24\u79cd\u65b9\u5f0f\uff0c\u624b\u5de5\u5237\u65b0\u548c\u81ea\u52a8\u5237\u65b0\uff0c\u9ed8\u8ba4\u4e3a\u624b\u5de5\u5237\u65b0\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u901a\u8fc7\u6211\u4eec
\u624b\u5de5\u7684\u6267\u884c\u67d0\u4e2a
Oracle
\u63d0\u4f9b\u7684\u7cfb\u7edf\u7ea7\u5b58\u50a8\u8fc7\u7a0b\u6216\u5305\uff0c\u6765\u4fdd\u8bc1\u7269\u5316\u89c6\u56fe\u4e0e\u57fa\u8868\u6570\u636e\u4e00\u81f4\u6027\u3002
\u8fd9\u662f\u6700\u57fa\u672c\u7684\u5237\u65b0\u529e\u6cd5\u4e86\u3002\u81ea\u52a8\u5237\u65b0\uff0c\u5176\u5b9e\u4e5f\u5c31\u662f
Oracle
\u4f1a\u5efa\u7acb\u4e00\u4e2a
job
\uff0c\u901a\u8fc7\u8fd9\u4e2a
job
\u6765
\u8c03\u7528\u76f8\u540c\u7684\u5b58\u50a8\u8fc7\u7a0b\u6216\u5305\uff0c\u52a0\u4ee5\u5b9e\u73b0\u3002




ON DEMAND
\u7269\u5316\u89c6\u56fe\u7684\u7279\u6027\u53ca\u5176\u548c
ON COMMIT
\u7269\u5316\u89c6\u56fe\u7684\u533a\u522b\uff0c\u5373\u524d\u8005\u4e0d\u5237\u65b0
(
\u624b
\u5de5\u6216\u81ea\u52a8
)
\u5c31\u4e0d\u66f4\u65b0\u7269\u5316\u89c6\u56fe\uff0c\u800c\u540e\u8005\u4e0d\u5237\u65b0\u4e5f\u4f1a\u66f4\u65b0\u7269\u5316\u89c6\u56fe\uff0c
\u2014\u2014
\u53ea\u8981\u57fa\u8868\u53d1\u751f\u4e86
COMMIT
\u3002


\u521b\u5efa\u5b9a\u65f6\u5237\u65b0\u7684\u7269\u5316\u89c6\u56fe\uff1a
create materialized view mv_name refresh force on demand
start with sysdate

next sysdate+1
\uff08\u6307\u5b9a\u7269\u5316\u89c6\u56fe\u6bcf\u5929\u5237\u65b0\u4e00\u6b21\uff09


\u4e0a\u8ff0\u521b\u5efa\u7684\u7269\u5316\u89c6\u56fe\u6bcf\u5929\u5237\u65b0\uff0c\u4f46\u662f\u6ca1\u6709\u6307\u5b9a\u5237\u65b0\u65f6\u95f4\uff0c\u5982\u679c\u8981\u6307\u5b9a\u5237\u65b0\u65f6\u95f4\uff08\u6bd4\u5982\u6bcf
\u5929\u665a\u4e0a
10
\uff1a
00
\u5b9a\u65f6\u5237\u65b0\u4e00\u6b21\uff09
\uff1a
create materialized view mv_name refresh force on demand
start with sysdate next to_date( concat( to_char( sysdate+1,'dd-mm-yyyy'),'
22:00:00'),'dd-mm-yyyy hh24:mi:ss')

3
\u3001
ON COMMIT
\u7269\u5316\u89c6\u56fe


ON COMMIT
\u7269\u5316\u89c6\u56fe\u7684\u521b\u5efa\uff0c\u548c\u4e0a\u9762\u521b\u5efa
ON DEMAND
\u7684\u7269\u5316\u89c6\u56fe\u533a\u522b\u4e0d\u5927\u3002\u56e0\u4e3a
ON DEMAND
\u662f\u9ed8\u8ba4\u7684\uff0c\u6240\u4ee5
ON COMMIT
\u7269\u5316\u89c6\u56fe\uff0c\u9700\u8981\u518d\u589e\u52a0\u4e2a\u53c2\u6570\u5373\u53ef\u3002

这个提示相当模糊,google到yangtingkun的blog,发现了查找详细原因的方法。
http://yangtingkun.itpub.net/post/468/13318

Oracle提供的DBMS_MVIEW.EXPLAIN_MVIEW过程可以帮助你快速定位问题的原因。下面通过一个例子来说明,如果通过这个过程来解决问题。
使用EXPLAIN_MVIEW 过程首先要建立MV_CAPABILITIES_TABLE表,建表的脚步是$ORACLE_HOME/rdbms/admin /utlxmv.sql。(EXPLAIN_MVIEW过程是两个过程的重载,一个输出到MV_CAPABILITIES_TABLE表,另一个以PL /SQL的VARRAY格式输出,为了简单起见,我们建立MV_CAPABILITIES_TABLE表)。
SQL> begin
2 dbms_mview.explain_mview('SELECT
3 A.COL1,B.COL1
4 FROM A,B
5 WHERE A.COL2 = B.COL2;');
6 end;
7 /
通过select capability_name, possible, msgtxt from mv_capabilities_table
where capability_name like 'REFRESH%';
可以查找出原因

经查,我这段sql错误原因是“物化视图日志没有基于rowid;物化视图引用的字段没有包含所有关联表的rowid”。
修改sql为:
CREATE MATERIALIZED VIEW LOG ON A WITH ROWID ;
CREATE MATERIALIZED VIEW LOG ON B WITH ROWID ;

CREATE MATERIALIZED VIEW MV_TEST
BUILD IMMEDIATE
REFRESH FAST ON COMMIT
AS
SELECT
A.COL1,B.COL1,A.ROWID AID,B.ROWID BID
FROM A,B
WHERE A.COL2 = B.COL2;

扩展阅读:芯片型号查询 ... ora12541tnsno listener ... ora error01031 ... ora-00054怎么解决 ... ora12543 tns无法连接 ... ora12541 tns 无监听程序 ... ora01033 一键解决 ... ora-00054原因及解决办法 ... ora-12545问题怎么解决 ...

本站交流只代表网友个人观点,与本站立场无关
欢迎反馈与建议,请联系电邮
2024© 车视网