如何手工回收段空间?
/*
create table --- emp1
delete
shrink space
*/
1、创建表emp1,构建大数据
SQL> select count(*) from emp1; COUNT(*) ---------- 229376
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.
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
此问题,留待以后解决.