oracle Bug 4287115(ora-12083)


今天公司开发在删除表时报错ora-12083,很是疑惑,数据字典记录的是表,而删除要用物化视图方式删除,如下:

SQL> DROP TABLE CODE_M_AGENCY;
DROP TABLE CODE_M_AGENCY
           *
ERROR at line 1:
ORA-12083: must use DROP MATERIALIZED VIEW to drop "EFMIS_36"."CODE_M_AGENCY"


SQL> DROP MATERIALIZED VIEW CODE_M_AGENCY;
DROP MATERIALIZED VIEW CODE_M_AGENCY
*
ERROR at line 1:
ORA-12003: materialized view "EFMIS_36"."CODE_M_AGENCY" does not exist

使用10046事件跟踪如下:

SQL>alter session set events '10046 trace name context forever,level 12';
SQL>drop table CODE_M_AGENCY;
SQL>alter session set events '10046 trace name context off';

查看跟踪文件报错的递归sql:

=================================================================================================================================================================
PARSING IN CURSOR #139894769163856 len=160 dep=1 uid=0 oct=3 lid=0 tim=1482995091131451 hv=2880999359 ad='e882b160' sqlid='gx4mv66pvj3xz'
select con#,type#,condlength,intcols,robj#,rcon#,match#,refact,nvl(enabled,0),rowid,cols,nvl(defer,0),mtime,nvl(spare1,0),spare2,spare3 from cdef$ where obj#=:1
END OF STMT
BINDS #139894769163856:
Bind#0
  oacdty=02 mxl=22(22) mxlc=00 mal=00 scl=00 pre=00
  oacflg=00 fl2=0001 frm=00 csi=00 siz=24 off=0
  kxsbbbfp=7f3bca04f3b8  bln=22  avl=04  flg=05
  value=451343
EXEC #139894769163856:c=0,e=54,p=0,cr=0,cu=0,mis=0,r=0,dep=1,og=4,plh=2570921597,tim=1482995091131499
FETCH #139894769163856:c=0,e=4,p=0,cr=2,cu=0,mis=0,r=0,dep=1,og=4,plh=2570921597,tim=1482995091131508
CLOSE #139894769163856:c=0,e=0,dep=1,type=3,tim=1482995091131516
EXEC #139894770891880:c=17998,e=210770,p=0,cr=83,cu=3,mis=0,r=0,dep=0,og=1,plh=0,tim=1482995091131554
ERROR #139894770891880:err=12083 tim=1482995091131562
WAIT #139894770891880: nam='SQL*Net break/reset to client' ela= 1 driver id=1650815232 break?=1 p3=0 obj#=-1 tim=1482995091131628
WAIT #139894770891880: nam='SQL*Net break/reset to client' ela= 38 driver id=1650815232 break?=0 p3=0 obj#=-1 tim=1482995091131679
WAIT #139894770891880: nam='SQL*Net message to client' ela= 0 driver id=1650815232 #bytes=1 p3=0 obj#=-1 tim=1482995091131693

*** 2016-12-29 15:05:01.030
WAIT #139894770891880: nam='SQL*Net message from client' ela= 9898906 driver id=1650815232 #bytes=1 p3=0 obj#=-1 tim=1482995101030616
CLOSE #139894770891880:c=0,e=17,dep=0,type=0,tim=1482995101030778
=================================================================================================================================================================

可以看到是在执行sql(已经替换绑定变量):select con#,type#,condlength,intcols,robj#,rcon#,match#,refact,nvl(enabled,0),rowid,cols,nvl(defer,0),mtime,nvl(spare1,0),spare2,spare3 from cdef$ where obj#=451343;

该sql在pl/sql devloper上执行结果为空。

好吧!我们来看一下正常情况下的drop table操作结果如何,步骤如下:

SQL> create table test01 as select * from user_objects;
SQL> alter session set events '10046 trace name context forever,level 12';
SQL> drop table test01;
SQL> alter session set events '10046 trace name context off';

取得跟踪文件后发现没有找到以上sql信息。

===================================

根据报错信息google查看,发现这是一个oracle bug,解释如下:

ISSUE CLARIFICATION
====================
After dropping the materialized view,while trying to drop the underlying table,
it failed with below error
When I try to drop the table it gives "ORA-12083: must use DROP MATERIALIZED
VIEW ..." .
.
ISSUE VERIFICATION
===================
Verified with error description above.
.
CAUSE DETERMINATION
====================
This is because of the Bug 4287115.
This is a known issue in 9i , which is fixed in 10g.
CAUSE JUSTIFICATION
====================
the bug description clearly matches the issue here.
.
POTENTIAL SOLUTION(S)
======================
To workaround the problem , connected as sys run the following update statement.
The following update should update only one row. In case if it updates more
than one row, then rollback the transaction, which means that this workaround
does not apply to your case.
connect sys/ as sysdba
update tab$ set property = property - 100663296 where
obj# in (select obj# from obj$ where name='OT_CR_ITEM_X' and
owner# in (select USER_ID from all_users where USERNAME=''));
commit;
alter system flush shared_pool;
alter system flush shared_pool;
alter system flush shared_pool;
connect /
Now try dropping the table & it should go through fine.

POTENTIAL SOLUTION JUSTIFICATION(S)
====================================
This is the recommended solution.
.
SOLUTION / ACTION PLAN
=======================
Hi Chunpeng,
This problem is not fixed in 9i,but you can try the workaround given above.
this is fixed in 10g.

安装步骤解决发现可以正常删除表,如下。

update tab$
   set property = property - 100663296
where obj# in
       (select obj#
          from obj$
         where name = 'CODE_M_DISTRICT'
           and owner# in (select USER_ID from all_users where USERNAME = 'EFMIS_36'));
commit;

原文地址:https://www.cnblogs.com/wcwen1990/p/6660424.html