使用shrink

总结:
实验过程
1 建立测试表 5000万行数据
2 删除其中40% 数据
3 测试回收终止 与回收速度


硬件环境
i3 cpu 笔记本
4G redhat 虚拟机 放在移动硬盘上USB2.0相连


1 建立测试表
create table test_shrink 
as 
select * from dba_objects 


2 插入数据
begin
for i in 1..1000
loop
insert into test_shrink
select * from dba_objects  ;
commit ;
end loop ;
end  ;


3 查看空间
select bytes/1024/1024/1024 
from user_segments  x
where x.segment_name=upper('test_shrink')


-----------------------
  4.8447265625


4 查看行数


51540544




5 删除一部分数据




6 
SQL> alter table SGW.TEST_SHRINK enable row movement;


Table altered.


Elapsed: 00:00:00.36
SQL> alter table SGW.TEST_SHRINK shrink space;




7 强行终止


SQL> alter table SGW.TEST_SHRINK shrink space;
alter table SGW.TEST_SHRINK shrink space
*
ERROR at line 1:
ORA-01013: user requested cancel of current operation




Elapsed: 00:20:58.85




8 继续回收


Elapsed: 00:02:02.51
SQL> alter table SGW.TEST_SHRINK shrink space;


Table altered.


Elapsed: 00:44:44.50




9 查看结果
SQL> select bytes/1024/1024/1024 
from dba_segments  x
  2    3  where x.segment_name=upper('test_shrink');


BYTES/1024/1024/1024
--------------------
          3.27655029


你可能感兴趣的:(使用shrink)