今天在删除表空间时遭遇报错ORA-00604&ORA-02429,下面分享一下解决问题的过程。
1)现象:
drop tablespace INX_TBS INCLUDING CONTENTS and datafiles;
在执行上述 drop tablespace语句时,数据库报错,提示:
“ORA-00604: 递归 SQL 级别 1 出现错误
ORA-02429: 无法删除用于强制唯一/主键的索引”。
2)查找主键,索引语句:
select 'alter table '||owner||'.'||table_name||' drop constraint '||constraint_name||' ;'
from dba_constraints
where constraint_type in ('U', 'P')
and (index_owner, index_name) in
(select owner, segment_name
from dba_segments
where tablespace_name = 'INDX_TBS');
3)原因
是因为有些业务表给错误的建立到了 sys用户下。
4) 解决方法:
使用sys用户以DBA登录,执行2)的sql语句,删除sys用户下的表和索引后,问题解决。
5)执行drop 语句
drop tablespace INX_TBS INCLUDING CONTENTS and datafiles;
drop 成功。