如何手工回收段空间?

/*

  create table --- emp1

  delete

  shrink space

*/

1、创建表emp1,构建大数据 

SQL> select count(*) from emp1;

  COUNT(*)
----------
    229376
View Code
SQL> select segment_name,blocks from user_segments where segment_name = 'EMP1';

SEGMENT_NAME                                           BLOCKS
-------------------------------------------------- ----------
EMP1                                                      384
查看段空间占用情况

2、删除表中数据,产生块的空洞

SQL> delete emp1 where empno in (7876,7369,7900,7499,7788);

81920 rows deleted.

SQL> commit;

Commit complete.
View Code
SQL> analyze table emp1 compute statistics;

Table analyzed.

SQL> select table_name,blocks from user_tables;

TABLE_NAME                         BLOCKS
------------------------------ ----------
EMP3                                  499
EMP1                                  338
EMP2                                  375
T                                       5
LIST1                                   0
COMPOSITE1                              0
RANGE2                               1256
RANGE1                                300
EMP                                   120

9 rows selected.
执行完删除操作之后,查看空间占用情况;没变;

3、执行shrink space功能

SQL> alter table emp1 enable row movement;

Table altered.
开启行移动功能
SQL> alter table emp3 enable row movement;

Table altered.

SQL> alter table emp3 shrink space;

Table altered.
执行收缩命令

在这里出现了一个小插曲,我的表空间明明是采用ASSM管理的,可是在执行收缩的时候,还是会出现错误:

SQL> alter table emp1 shrink space;
alter table emp1 shrink space
*
ERROR at line 1:
ORA-10635: Invalid segment or tablespace type

此问题,留待以后解决.

posted @ 2013-06-09 10:28  ArcerZhang  阅读(234)  评论(0编辑  收藏  举报