1、重组织表模式:
(1)OFFLINE
⊙ MOVE表
⊙ CTAS
◎ Create Table As Select
◎ index
◎ constrain
◎ drop old table
◎ rename new table
⊙ EXP/IMP,EXPDP/IMPDP
⊙ REBUILD
(2)ONLINE
alter table <table> shrink space <compact>;
alter index <index> shrink space <compact>;
--------------------------------------------------------------------------------
1、OFFLINE
分两种方式:offline,cats
(1)MOVE表
⊙ 基于表的MOVE操作
⊙ 在执行MOVE时,查询仍然执行
⊙ MOVE后索引失效,需要REBUILD
⊙ DML的受限时间 = MOVE的时间 + REBUILD 索引的时间
⊙ 查询的受限时间 = REBUILD 索引的时间,因为索引无法使用.
所以,MOVE表的时候,如果不使用索引,那么查询没有影响
(2)CTAS实现的方式: ( Create Table As Select)
1) Create table as select (create table t as select * from test;)
2) index
3) constrain
4) drop old table
5) rename new table
该方法,DML时跟MOVE同样的受限时间,查询的受限时间非常短 = DROP OLD TABLE + RENAME NEW TABLE,
drop table,我们说通常是很快的, 需要更多的空间 = 2倍表大小 + 2倍索引大小
2、online
alter table <table> shrink space <compact>;
alter index <index> shrink space <compact>;
rebuild和coalesce(shrink space )的优点及成本:
rebuild index coalesce index
能快速在表空间移动 不能实现表空间移动
磁盘空间需要高成本 磁盘空间低成本,不需要很多磁盘空间
需要重建整个索引 只整合一个分支节点下的页块
能快速改变存储参数 只能用于整理页块
ORACLE提供了分析索引结构的语法: ANALYZE INDEX … VALIDATE STRUCTURE