ORACLE11G支持在standby只读打开数据库,可供报表查询使用。
最近遇到一个奇怪的事,突然间发现视图不能用,报如下错误:
ORA-04045:在重新编译/重新验证 某视图报错。
紧接着报了ORA-16000的错误,打开数据库进行只读访问。
分别查看两个错误信息:
[oracle@test ~]$ oerr ora 04045
04045, 00000, "errors during recompilation/revalidation of %s.%s"
// *Cause: This message indicates the object to which the following
// errors apply. The errors occurred during implicit
// recompilation/revalidation of the object.
// *Action: Check the following errors for more information, and
// make the necessary corrections to the object.
[oracle@test ~]$ oerr ora 16000
16000, 00000, "database open for read-only access"
// *Cause: The database was opened for read-only access. Attempts to
// modify the database using DML or DDL statements generate this
// error.
// *Action: In order to modify the database, it must first be shut down and
// reopened for read/write access
从错误中可以看出,第一个错误是视图经过修改,第二个错误是在standby节点时进行编译是说数据库只读。
但可以看到的是该视图在主节点是可以执行的,后来经过分析查询,操作人员对原来的字段进行了扩展,引起备节点的报错。原因是在备节点时,内存里信息没有更新,后来进行查询时,发现与本地有差异,进行重新编译报错。
解决办法,就是在主节点对该视图进行了重建,再查询时,问题解决!