Oracle shrinks the table to release the occupied storage space (shrink space)
Oracle shrinks the table to release the occupied storage space (shrink space)
1. Enable the row movement function of the table (enable row movement)
On SQL:
alter table BIG_TABLE enable row movement;
2. Shrink space cascade
Shrink space cascade, defragment, lower high water mark.
On SQL:
alter table BIG_TABLE shrink space cascade;
3. Turn off the row movement function of the table (disable row movement)
On SQL:
alter table BIG_TABLE disable row movement;
4. Extension of knowledge points
4.1. SQL to check whether the index is invalid
SELECT index_name
,tablespace_name
,status
,visibility
FROM dba_indexes
WHERE table_name = 'BIG_TABLE';
4.2. The shrink space cascade does not need to invalidate the index or rebuild the index.
4.3. Using the move command to defragment will invalidate the index and requires rebuilding the index.
alter table BIG_TABLE move;
4.3.1. Rebuild index
alter index BIG_TABLE_PK rebuild;