Oracle中删除表空间时,遇到了ORA-14404错误。
 
错误信息如下:
SQL> DROP TABLESPACE PART1 INCLUDING CONTENTS AND DATAFILES;
DROP TABLESPACE PART1 INCLUDING CONTENTS AND DATAFILES
ORA-14404: partitioned table contains partitions in a different tablespace
 
同样查看官方文档的说明:
Oracle Error: ORA-14404

Error Description:
Partitioned table contains partitions in a different tablespace

Error Cause:
An attempt was made to drop a tablespace which contains tables whose partitions are not completely contained in this tablespace.

Action:
Find tables with partitions which span the tablespace being dropped and some other tablespace(s). Drop these tables or move partitions to a different tablespace.
 
问题分析:
ORA-14404错误说明有某个表不仅仅只在当前表空间,在其他表空间也存有数据。解决方法,Oracle的建议也比较清晰,要么删除这个表,要么把移动partitions到一个单独的表空间中。对于我来说,我删除此表即可。
 
首先需要找到到底是哪张表跨越了不同表空间:
SQL> SELECT x.table_name,x.partition_name,x.tablespace_name 表空间1, y.tablespace_name 表空间2
  2  FROM dba_tab_partitions x, dba_tab_partitions y
  3  WHERE x.tablespace_name ='PART1' AND y.tablespace_name <> 'PART1' AND x.table_name=y.table_name;
TABLE_NAME                     PARTITION_NAME                 表空间1                        表空间2
------------------------------ ------------------------------ ------------------------------ ------------------------------
RANGE_PART                     YR0                            PART1                          PART2
RANGE_PART                     YR0                            PART1                          PART3
RANGE_PART                     YR0                            PART1                          PART4

即找到名称为RANGE_PART的分区表的数据在表空间PART1、PART2和PART3上,接下来删除此表即可。
SQL> drop table RANGE_PART;
Table dropped