您的位置:首页技术文章
文章详情页

Oracle诊断案例-Sql_trace之二

【字号: 日期:2023-11-20 19:31:03浏览:41作者:猪猪
link:http://www.eygle.com/case/sql_trace_2.htm问题说明:很多时候在我们进行数据库操作时比如drop user,drop table等,经常会碰到这样的错误 ORA-00604: error occurred at recursive SQL level 1 . 这样的提示,很多时候是没有丝毫用处的.本案例就这一类问题提供一个思路及方法供大家参考.1. drop user出现问题报出以下错误后退出ORA-00604: error occurred at recursive SQL level 1 ORA-00942: table or view does not exist .关于 recursive SQL 错误我们有必要做个简单说明.我们知道,当我们发出一条简单的命令以后 Oracle数据库要在后台解析这条命令,并转换为Oracle数据库的一系列后台操作.这些后台操作统称为递归sql比如create table这样一条简单的DDL命令Oracle数据库在后台,实际上要把这个命令转换为对于obj$,tab$,col$等底层表的插入操作.Oracle所作的工作可能比我们有时候想的要复杂的多. 2.跟踪问题我们知道Oracle提供sql_trace的功能可以用于跟踪Oracle数据库的后台递归操作.通过跟踪文件,我们可以找到问题的所在以下是格式化(tkprof)后的输出:********************************************************************************The following statement encountered a error during parse:DELETE FROM SDO_GEOM_METADATA_TABLE WHERE SDO_OWNER = 'WAPCOMM' Error encountered: ORA-00942********************************************************************************Oracle把错误信息首先呈现出来我们看到ORA-00942错误是由于SDO_GEOM_METADATA_TABLE表/视图不存在所致问题由此可以定位对于这一类的错误,定位问题以后解决的方法就要依据具体问题原因而定了。3.问题定位对于本案例,通过Metalink获得以下解释:Problem Description ------------------- The Oracle Spatial Option has been installed and you are encountering the following errors while trying to drop a user, who has no spatial tables, connected as SYSTEM: ERROR at line 1: ORA-00604: error occurred at recursive SQL level 1 ORA-00942: table or view does not exist ORA-06512: at line 7 A 942 error trace shows the failing SQL statement as: DELETE FROM SDO_GEOM_METADATA_TABLE WHERE SDO_OWNER = '<user>' Solution Description -------------------- (1) Create a synonym for SDO_GEOM_METADATA_TABLE under SYSTEM which points to MDSYS.SDO_GEOM_METADATA_TABLE. 对于本例,为MDSYS.SDO_GEOM_METADATA_TABLE创建一个同义词即可解决.是相对简单的情况.(2) Now the user can be dropped connected as SYSTEM. Related Documents ----------------- <Note.159776.1> ORA-604 and ORA-942 Reported During DROP USER CASCA4.实际处理MDSYS.SDO_GEOM_METADATA_TABLE为Spatial对象假如未使用Spatial选项,可以删除 SQL> connect / as sysdbaConnected. SQL> select * from dba_sdo_geom_metadata order by owner; select * from dba_sdo_geom_metadata order by owner*ERROR at line 1:ORA-00942: table or view does not existORA-04063: view 'MDSYS.DBA_SDO_GEOM_METADATA' has errorsSQL> select object_name from dba_objects where object_name like '%SDO%';OBJECT_NAME--------------------------------------------------------------------------------ALL_SDO_GEOM_METADATAALL_SDO_INDEX_INFOALL_SDO_INDEX_METADATADBA_SDO_GEOM_METADATADBA_SDO_INDEX_INFODBA_SDO_INDEX_METADATA....DBA_SDO_GEOM_METADATADBA_SDO_INDEX_INFO...SDO_WITHIN_DISTANCEUSER_SDO_GEOM_METADATAUSER_SDO_INDEX_INFOUSER_SDO_INDEX_METADATA88 rows selected.SQL> drop user MDSYS cascade;User dropped.SQL> select owner,type_name from dba_types where type_name like 'SDO%';no rows selectedSQL> SQL> alter session set sql_trace=true;Session altered.SQL> drop user wapcomm;User dropped.SQL> alter session set sql_trace=false;Session altered.SQL> exitDisconnected from Oracle8i Enterprise Edition Release 8.1.7.4.0 - 64bit ProdUCtionWith the Partitioning optionJServer Release 8.1.7.4.0 - 64bit Production这时用户得以顺利drop5.一点总结使用sql_trace可以跟踪数据库的很多后台操作有利于我们发现问题的所在很多时候,我们想要研究Oracle的内部活动或后台操作也可以通过sql_trace跟踪sql_trace/10046 是Oracle提供的最为有效的诊断工具之一.
标签: Oracle 数据库