This shows that "alter table x move" reclaims the space.
As seen here in: http://www.dba-oracle.com/t_alter_table_move_shrink_space.htm
It says it doesn't change the table size.
SQL> begin
2 for i in 1..1000000 loop
3 insert into audadm.t1 values (i);
4 end loop;
5 commit;
6 end;
7 /
PL/SQL procedure successfully completed.
SQL> analyze table audadm.t1 compute statistics;
Table analyzed.
SQL> select blocks,empty_blocks,num_rows from dba_tables where table_name='T1';
BLOCKS EMPTY_BLOCKS NUM_ROWS
---------- ------------ ----------
2276 1819 1500000
SQL> select blocks, extents from dba_segments where segment_name='T1';
BLOCKS EXTENTS
---------- ----------
4096 2
SQL> select sum(bytes) from dba_segments where segment_name = 'T1';
SUM(BYTES)
----------
33554432
SQL> delete from audadm.t1 where mod(x,2)=0;
500000 rows deleted.
SQL> commit;
Commit complete.
SQL> analyze table audadm.t1 compute statistics;
Table analyzed.
SQL> select blocks,empty_blocks,num_rows from dba_tables where table_name='T1';
BLOCKS EMPTY_BLOCKS NUM_ROWS
---------- ------------ ----------
2276 1819 1000000
SQL> select blocks, extents from dba_segments where segment_name='T1';
BLOCKS EXTENTS
---------- ----------
4096 2
SQL> select sum(bytes) from dba_segments where segment_name = 'T1';
SUM(BYTES)
----------
33554432
SQL> alter table audadm.t1 move;
Table altered.
SQL> analyze table audadm.t1 compute statistics;
Table analyzed.
SQL> select blocks,empty_blocks,num_rows from dba_tables where table_name='T1';
BLOCKS EMPTY_BLOCKS NUM_ROWS
---------- ------------ ----------
1520 527 1000000
SQL> select blocks, extents from dba_segments where segment_name='T1';
BLOCKS EXTENTS
---------- ----------
2048 1
SQL> select sum(bytes) from dba_segments where segment_name = 'T1';
SUM(BYTES)
----------
16777216
SQL>
No comments:
Post a Comment