在前几天的log中提到了如何将system表空间从dictionary-management tablespace转换为local management tablespace。
在本文中将讲述dbms_space_Admin.tablespace_migrate_to_local的另一个实用的案例。
当我们需要drop 一个包含很多extents的数据字典管理表空间是一件比较头痛的问题。
他需要不停的访问UET$和FET$表,执行插入,删除操作,长期占有ST enqueue,造成数据库长时间无法allocate和deallocate extents,情况严重可能会造成很严重的后果。
如何减少drop tablespace的时间呢?请看下面这个例子
例子取自metalink note:311512.1
执行时间从50多分钟减少到1分钟左右
Following are the test results -
CASE 1 - Dropping a DMT directly
-----------------------------------------------
SQL> select bytes,count(*) from dba_extents where tablespace_name='DMT_DROP' group by bytes;
BYTES COUNT(*)
---------- ----------
2048 92359
4096 1
14:41:42 SQL> drop tablespace dmt_drop including contents;
Tablespace dropped.
15:32:31 SQL>
-----> Takes around 50 minutes to drop.
CASE 2 - Dropping a DMT after converting to LMT
--------------------------------------------------------------------
select bytes,count(*) from dba_extents where tablespace_name='DMT_DROP' group by bytes;
BYTES COUNT(*)
---------- ----------
2048 92359
4096 1
17:00:33 SQL> exec dbms_space_Admin.tablespace_migrate_to_local(tablespace_name=>'DMT_DROP')
PL/SQL procedure successfully completed.
17:01:14 SQL> drop tablespace dmt_drop including contents;
Tablespace dropped.
17:01:32 SQL>
-----> Takes around 1 minute to drop.
在8i,需要把init.ora的compatible = 8.1.0改为compatible = 8.1.6,否则会出现兼容性警告,运行不了该PROCEDURE