Total Pageviews

Sunday, 15 January 2012

Claim freespace using shrink and shrink space compact

SQL> @show_space_table.sql
Unformatted Blocks .....................             748
FS1 Blocks (0-25)  .....................               0
FS2 Blocks (25-50) .....................           7,742
FS3 Blocks (50-75) .....................             254
FS4 Blocks (75-100).....................              62
Full Blocks        .....................             271
Total Blocks............................           9,216
Total Bytes.............................      75,497,472
Total MBytes............................              72
Unused Blocks...........................               0
Unused Bytes............................               0
Last Used Ext FileId....................               4
Last Used Ext BlockId...................           2,688
Last Used Block.........................           1,024
 
PL/SQL procedure successfully completed.
SQL> select sum(bytes) from user_extents where segment_name='TEST_CHAINED_TABLE';
 
SUM(BYTES)
----------
  75497472
 
SQL> alter table test_chained_table shrink space compact;
alter table test_chained_table shrink space compact
*
ERROR at line 1:
ORA-10636: ROW MOVEMENT is not enabled
 
 
SQL> alter table test_chained_table enable row movement;
 
Table altered.
 
SQL> alter table test_chained_table shrink space compact;
 
Table altered.
 
SQL> select sum(bytes) from user_extents where segment_name='TEST_CHAINED_TABLE';
 
SUM(BYTES)
----------
  75497472
 
SQL> @show_space_table.sql
Unformatted Blocks .....................             748
FS1 Blocks (0-25)  .....................               0
FS2 Blocks (25-50) .....................               1
FS3 Blocks (50-75) .....................               0
FS4 Blocks (75-100).....................           3,169
Full Blocks        .....................           5,159
Total Blocks............................           9,216
Total Bytes.............................      75,497,472
Total MBytes............................              72
Unused Blocks...........................               0
Unused Bytes............................               0
Last Used Ext FileId....................               4
Last Used Ext BlockId...................           2,688
Last Used Block.........................           1,024
 
PL/SQL procedure successfully completed.
 
SQL> alter table test_chained_table shrink space;
 
Table altered.
 
SQL>  select sum(bytes) from user_extents where segment_name='TEST_CHAINED_TABLE';
 
SUM(BYTES)
----------
  43057152
 
SQL> @show_space_table.sql
Unformatted Blocks .....................               0
FS1 Blocks (0-25)  .....................               0
FS2 Blocks (25-50) .....................               1
FS3 Blocks (50-75) .....................               0
FS4 Blocks (75-100).....................               0
Full Blocks        .....................           5,159
Total Blocks............................           5,256
Total Bytes.............................      43,057,152
Total MBytes............................              41
Unused Blocks...........................               4
Unused Bytes............................          32,768
Last Used Ext FileId....................               4
Last Used Ext BlockId...................          11,648
Last Used Block.........................               4
 
PL/SQL procedure successfully completed.
 
SQL> alter table test_chained_table disable row movement;
 
Table altered.

No comments:

Post a Comment