日期:2014-05-16 浏览次数:20584 次
您知道在 oracle 上创建物化视图时,需要注意到什么吗?在出错的时候,该如何调试吗?
我最近遇到这样一个问题。在创建一个每天一次、全量更新物化视图时出错了。
报的错误是 ORA-6512 ,是 关于SYS.DBMS_SNAPSHOT_UTL 包的。
这是系统包的错误,这会是Oracle bug吗?
物化视图脚本很简单,同步异地的一个数据库中的一张表到本地数据库中来,属于常见的数据同步操作。
异地和本地的数据库版本都是 Oracle 10.2.0.3 。
CREATE MATERIALIZED VIEW V_JW_COURSETIMETABLE
REFRESH COMPLETE ON DEMAND
START WITH TO_DATE('28-05-2012 21:47:56', 'DD-MM-YYYY HH24:MI:SS') NEXT SYSDATE + 1
AS
SELECT WID AS WID, KCM as KCM, JXBH AS JXBH, KKNF AS KKNF, KKXQM AS KKXQM, XQ AS XQ, JS AS JS, ZS AS ZS, JSGH AS JSGH
FROM USR_GXSJ.V_JW_COURSETIMETABLE@lk_rs_dpstar
where
(KKNF = '2011' AND KKXQM = '1') OR (KKNF = '2011' AND KKXQM = '2')
还有一点很郁闷。该物化视图之前是创建成功的,现在是删除掉重建就不行了。
(miki 西游的文档:原文链接链接 :? http://mikixiyou.iteye.com/blog/1543973?? 转载请著明出处和作者)
?
1.分析
我们首先检查物化视图创建语法,完全没有看出来错误。
我们再核实其中的 SELECT? 操作,也能正常执行出结果。
之前这个物化视图视图是存在的,只是删除掉略作字段调整而重建一下而已。?
现在,我们该如何去分析和解决这个问题呢?
?
查官方文档:
在 oracle????? metalink? 查阅到这些信息,有一个 bug5015547? ,他的描述信息同我们的错误完全一致。文档为 Bug 5015547 : CANNOT CREATE A MATERIALIZED VIEW OVER A DATABASE LINK OR? A-942
文档中的信息如下:
Bug 5015547 : CANNOT CREATE A MATERIALIZED VIEW OVER A DATABASE LINK ORA-942
------------------
Security setup is :
Local side :
user_d - materialized view owner;
Remote side :
user_a - table owner;
user_b - has view on table in user_a's schema
user_c - has select privs on view in user_b's schema.
?
connect User_D/User_D
drop materialized view User_D.Table1;
CREATE MATERIALIZED VIEW User_D.Table1????? REFRESH WITH ROWID????? AS SELECT * FROM
?
the statement which is failing is :
ORA-942: table or view does not exist
ORA-6512: at "SYS.DBMS_SNAPSHOT_UTL", line 1543
ORA-2063: preceding 2 lines from TARMM
因为有如此类似的 bug 信息,所以决定先安装一下补丁包,试试看能否解决掉这个问题。?
(注,这里开始走了弯路,不相信自己判断,盲从官方文档)
2.解决过程
2.1安装补丁包
这是一个 RAC 架构的数据库,因此需要在每个节点上依次安装补丁包 5015547
安装过程如下:大家可以参考一下如何在 RAC 下依次安装小补丁包。
???????? 一个节点一个节点地关闭数据库实例,ASM? 实例,监听器应用
?
/data/oracle/home/5015547@edbrac3=>+ASM3$opatch apply -local????????????
Invoking OPatch 10.2.0.3.0
Oracle interim Patch Installer version 10.2.0.3.0
Copyright (c) 2005, Oracle Corporation.? All rights reserved..
Oracle Home?????? : /opt/app/oracle/product/10.2.0/db_1
Central Inventory : /opt/app/oracle/oraInventory
?? from?????????? : /var/opt/oracle/oraInst.loc
OPatch version??? : 10.2.0.3.0
OUI version?????? : 10.2.0.3.0
OUI location????? : /opt/app/oracle/product/10.2.0/db_1/oui
Log file location : /opt/app/oracle/product/10.2.0/db_1/cfgtoollogs/opatch/opatch2012-05-28_13-11-46PM.log
ApplySession applying interim patch '5015547' to OH '/opt/app/oracle/product/10.2.0/db_1'
Invoking fuser to check for active processes.
Invoking fuser on "/opt/app/oracle/product/10.2.0/db_1/bin/oracle"
You selected -local option, hence OPatch will patch the local system only.
Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.
(Oracle Home = '/opt/app/oracle/product/10.2.0/db_1')
Is the local system ready for patching?
Do you want to proceed? [y|n]
y
User Responded with: Y
Backing up files and inventory (not for auto-rollback) for the Oracle Home
Backing up files affected by the patch '5015547' for restore. This might take a while...
^[Backing up files affected by the patch '5015547' for rollback. This might take a while...
Patching component