ORA-22868: 具有LOB 的表包含有位于不同表空间的段

由于lob对象引起的表空间无法删除。本来是要删除DMS表空间,但是上面有LOB对象,而且表却是在别的表空间DMS4上。解决的办法就是将这些lob移动到DMS4表空间。
下面是解决过程

删除用户时报错:

drop tablespace dms

第 1 行出现错误:
ORA-01549: 表空间非空, 请使用 INCLUDING CONTENTS 选项

SQL> drop tablespace dms including contents and datafiles;
drop tablespace dms including contents and datafiles
*
第 1 行出现错误:
ORA-22868: 具有 LOB 的表包含有位于不同表空间的段

检查这个表空间上的Lob对象:
SQL> select owner, table_name, column_name, tablespace_name from dba_lobs where tablespace_name = 'DMS';

已选择6行。

小白批注:这条命令相当有用,小白通过这个命令查找到了lob对象,然后删掉他们,再删一次表空间,就OK了~

另外再检查下约束有没有问题(因为这个问题常见,所以一并检查了下)。
SQL> 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 = 'DMS');


未选定行
SQL>

解决过程:

下面是我写的脚本,这个脚本可以生成要用的语句。
      
select 'alter table ' || xtable || ' move tablespace DMS4 lob' || '(' ||
       column_name || ') store as ( tablespace DMS4);'
  from (select xtable, wmsys.wm_concat(column_name) column_name
          from (select owner || '.' || table_name xtable,
                       column_name,
                       tablespace_name
                  from dba_lobs
                 where tablespace_name = 'DMS')
         group by xtable)


结果如下:
alter table DMS4.xxxx move tablespace DMS4 lob(ERROR_TEXT) store as ( tablespace DMS4);


取消dms4在dms表空间上的限额,防止再出类似问题。
alter user dms4 quota 0 on dms;

源地址:http://blog.csdn.net/bamuta/article/details/12492783

 

你可能感兴趣的:(ORA-22868: 具有LOB 的表包含有位于不同表空间的段)