Oracle删除用户错误

案例四:Sql_trace进行Oracle诊断案例

  问题说明:很多时候,在我们进行数据库操作时,比如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 = ''
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
ORA-604 and ORA-942 Reported During DROP USER CASCA  

4.实际处理

  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 exist
ORA-04063: view "MDSYS.DBA_SDO_GEOM_METADATA" has errors
SQL> select object_name from dba_objects where object_name like '%SDO%';
OBJECT_NAME
ALL_SDO_GEOM_METADATA
ALL_SDO_INDEX_INFO
ALL_SDO_INDEX_METADATA
DBA_SDO_GEOM_METADATA
DBA_SDO_INDEX_INFO
DBA_SDO_INDEX_METADATA
....
DBA_SDO_GEOM_METADATA
DBA_SDO_INDEX_INFO
...
SDO_WITHIN_DISTANCE
USER_SDO_GEOM_METADATA
USER_SDO_INDEX_INFO
USER_SDO_INDEX_METADATA
88 rows selected.
SQL> drop user MDSYS cascade;
User dropped.
SQL> select owner,type_name from dba_types where type_name like 'SDO%';
no rows selected
SQL>
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> exit
Disconnected from Oracle8i Enterprise Edition Release 8.1.7.4.0 - 64bit Production
With the Partitioning option
JServer Release 8.1.7.4.0 - 64bit Production

  这时用户得以顺利drop

你可能感兴趣的:(oracle)