drop物化视图log表导致insert、delete、update报ORA-00942

之前基于emp表测试物化视图创建了 物化视图log表,测试完成后清理不用的表 直接drop table 物化视图log表,过段时间再用emp表的时候发现:
    select emp正常,但是insert、delete、update就报 ORA-00942: table or view does not exist

下面重现这个问题:
#创建物化视图log表在emp上
SQL> create materialized view log on emp  with rowid;
Materialized view log created.

SQL> select * from tab;

TNAME                          TABTYPE  CLUSTERID
------------------------------ ------- ----------
BONUS                          TABLE
DEPT                           TABLE
EMP                            TABLE
MLOG$_EMP                      TABLE
SALGRADE                       TABLE

#直接删除log表
SQL> drop table MLOG$_EMP purge;
Table dropped.
SQL> select * from tab;
TNAME                          TABTYPE  CLUSTERID
------------------------------ ------- ----------
BONUS                          TABLE
DEPT                           TABLE
EMP                            TABLE
SALGRADE                       TABLE

#进行select、insert、update、delete操作:
SQL> select count(*) from emp;


  COUNT(*)
----------
        14

#发现 insert、delete、update报ORA-00942
SQL> update emp set empno=empno+1;
update emp set empno=empno+1
       *
ERROR at line 1:
ORA-00942: table or view does not exist

SQL> delete emp where empno=7379;
delete emp where empno=7379
       *
ERROR at line 1:
ORA-00942: table or view does not exist

SQL> insert into emp(empno) values(1);
insert into emp(empno) values(1)
            *
ERROR at line 1:
ORA-00942: table or view does not exist

解决方法:
#查出dba_mview_logs中存在,而的log表不存在的对象
 select 'drop materialized view log on '||mvl.log_owner||'.'||mvl.master||';'  cmd  from dba_mview_logs mvl  where not exists  ( select table_name from dba_tables tab  where tab.owner = mvl.log_owner and tab.table_name = mvl.log_table  ) ;
CMD
--------------------------------------------------------------------------------
drop materialized view log on SCOTT.EMP;
#执行正确的删除  materialized view log  语句
SQL> drop materialized view log on SCOTT.EMP;
Materialized view log dropped.

#问题解决
SQL> delete emp where empno=7379;

1 row deleted.

SQL> rollback;

Rollback complete.


参考mos文章:
单击此项可添加到收藏夹 ORA-00942 when deleting from an existing Table after dropping materialized view log table (文档 ID 1912363.1) 转到底部转到底部

修改时间:2014-8-4类型:PROBLEM
为此文档评级 通过电子邮件发送此文档的链接 在新窗口中打开文档 可打印页

In this Document

Symptoms
Cause
Solution
References


APPLIES TO:

Oracle Database - Enterprise Edition - Version 11.2.0.3 and later
Information in this document applies to any platform.

SYMPTOMS

Delete from an existing table fails with ORA-942. The table exists in dba_objects view with valid status.

CAUSE

If a materialized view log table is dropped by a different method than "DROP MATERIALIZED VIEW LOG" it can cause DMLs over the source table to raise ORA-942 errors. 

 The call stack show the following functions :

kxtrcpy kntkca kntkcai kntclc

SOLUTION

Please use the below query to identify the Materialised view log:

 
SQL> select 'drop materialized view log on '||mvl.log_owner||'.'||mvl.master||';'  cmd  from dba_mview_logs mvl  where not exists  ( select table_name from dba_tables tab  where tab.owner = mvl.log_owner and tab.table_name = mvl.log_table  )  / 
  Sample output:
CMD -------------------------------------------------------------------------------- drop materialized view log on EDA_STD_REPORT_ADM.STATICREPORTS;
   

Drop the related materialized view log and then perform the other DML operation.

 

REFERENCES











来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/27000195/viewspace-1400038/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/27000195/viewspace-1400038/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值