论坛上有人问 shrink 表后 要不要重建索引,答案是不用。实验如下:
SQL> conn system/yang as sysdba
已连接。
SQL> create table t tablespace test as select * from all_objects where rownumcreate table t tablespace test as select * from all_objects where rownum *
第 1 行出现错误:
ORA-00955: 名称已由现有对象使用
SQL> drop table t purge;
表已删除。
SQL> create table t tablespace test as select * from all_objects where rownum表已创建。
SQL> create index i_objectid on t (object_id);---建立索引
索引已创建。
SQL> delete from t where object_name like '%C%';
已删除954行。
SQL> delete from t where object_name like '%U%';
已删除216行。
SQL> alter table t enable row movement;
--shrink操作本质上是移动行的,所以要先执行此句。
表已更改。
SQL> alter table t shrink space;
表已更改。
SQL> select index_name,status from user_indexes where index_name='I_OBJECTID';
INDEX_NAME STATUS
------------------------------ --------
I_OBJECTID VALID
由此,证明shrink后,不用重建索引。。