Oracle 收缩段
时间:2010-12-02 来源:ank
测试:
SQL>conn / as sysdba
SQL>grant sysdba to hr
SQL>conn hr/passwd
--建立表,注意:其表空间的段管理方式为auto
SQL> create table tb_shrink_test as select * from dba_objects;
Table created.
--查看使用的块
SQL> select blocks from dba_segments where segment_name='TB_SHRINK_TEST' ;
BLOCKS
768
SQL> delete from tb_shrink_test;
50328 rows deleted.
SQL> commit;
Commit complete.
SQL> select blocks from dba_segments where segment_name='TB_SHRINK_TEST' ;
BLOCKS
768
--报错,使用收缩段,必须在该表上激活row movement
SQL> alter table tb_shrink_test shrink space;
alter table tb_shrink_test shrink space
*
ERROR at line 1:
ORA-10636: ROW MOVEMENT is not enabled
SQL> alter table tb_shrink_test enable row movement;
Table altered.
--try
SQL> alter table tb_shrink_test shrink space;
Table altered.
--再次查询blocks使用量
SQL> select blocks from dba_segments where segment_name='TB_SHRINK_TEST' ;
BLOCKS
8
---------end
补充,改表建立在example表空间上,segment未auto。如果是manual,
则会报错
SQL> alter table tb_manual shrink space
2 ;
alter table tb_manual shrink space
*
第 1 行出现错误:
ORA-10635: Invalid segment or tablespace type
SQL> select tablespace_name,segment_space_management from dba_tablespaces;
TABLESPACE_NAME SEGMEN
SYSTEM MANUAL
UNDOTBS1 MANUAL
SYSAUX AUTO
TEMP MANUAL
USERS AUTO
EXAMPLE AUTO
INDX AUTO
TS_AUTO AUTO
8 rows selected.