1、问题描述
确认数据库表空间不在使用,使用命令删除时,报错:
2、业务场景
如:测试数据库,需要清理不需要用户后,需要删除对应用户下多余表空间,以释放磁盘空间,如测试数据库impdp操作等情况 ,生产数据库谨慎操作。
3、解决方案
(1)查找唯一、主键、外键等索引情况:
同时报ORA-00604&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 = '要删除表空间名');
得到上面框中命令,执行命令即可;
4、注意
注意删除表空间,一定要确认数据库ip是否是正确的,避免人为误操作,导致删错实例下表空间!!!