首页 > Linux操作系统 > Linux操作系统 > SHRINK SPACE
第一)表:
一般表里有碎片采用alter table table_name move tablespace_name,或者exp,drop table table_name,imp的2种方式10G给我们其他的方法
drop table table;
create table table;
insert into table;
delete table --发现碎片
去除碎片方式:
1):alter table t move;
2): alter table t enable row movement;alter table t shrink space compact cascade;[效果不是很明显]
1:普通表
shrink必须开启行迁移功能。
alter table table_name enable row movement ;
保持HWM
alter table table_name shrink space compact;
回缩表与HWM
alter table table_name shrink space;
回缩表与相关索引
alter table table_name shrink space cascade;
回缩索引
alter index index_name shrink space;
第二)临时表空间:
(1)“SHRINK SPACE”之前的临时表空间查看sys@ora11g> select tablespace_name,file_id,bytes/1024/1024 Mbytes,blocks,maxbytes/1024/1024 MmaxBytes,maxblocks from dba_temp_files;
TABLESPACE_NAME FILE_ID MBYTES BLOCKS MMAXBYTES MAXBLOCKS--------------- ---------- ---------- ---------- ---------- ----------TEMP 1 29 3712 32767.9844 4194302
(2)使用“SHRINK SPACE”功能对临时表空间进行缩减sys@ora11g> alter tablespace TEMP shrink space;或alter tablespace TEMP shrink space keep 2m;
Tablespace altered.
(3)“SHRINK SPACE”之后临时表空间查看,可以看到临时表空间大小由原来的29M变成了现在的不到2M的大小。
sys@ora11g> select tablespace_name,file_id,bytes/1024/1024 Mbytes,blocks,maxbytes/1024/1024 MmaxBytes,maxblocks from dba_temp_files;
TABLESPACE_NAME FILE_ID MBYTES BLOCKS MMAXBYTES MAXBLOCKS--------------- ---------- ---------- ---------- ---------- ----------TEMP 1 1.9921875 255 32767.9844 4194302
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26667895/viewspace-715920/ ,如需转载,请注明出处,否则将追究法律责任。