Professional Documents
Culture Documents
Generally tables on which frequent update,delete and insert operations are performed gets fragmented. As a result of which the table occupies more space than what is required by it. This leads to reading of more data blocks during full scan. Thus increasing the response time of queries on that table. In order to overcome this type of problem we need to identify the tables that are candidates for shrink operation. The S G! "T A#$IS%& enables us to do so. 'or the demonstration let us do the followings () *reate a table +) ,opulate it with records -) #elete few records .) Again insert few records /) &epeat steps + 0 . few times in order to create the fragmentation 1) 'inally run the segment advisor to get recommendations 2) Shrink the segment S345 create table hr.emp + as - select 6 from hr.employees . where (78(9 1 Table created.
S345
2 S345 begin + . / for i in (..(::: loop insert into hr.emp select 6 from hr.employees9 end loop9
S345 begin + . / 1 for i in (../:: loop insert into hr.emp select 6 from hr.employees9 commit9 end loop9
2 end9 = ;
S345 begin + . / 1 for i in (../:: loop insert into hr.emp select 6 from hr.employees9 commit9 end loop9
2 end9 = ;
S345 commit9
*ommit complete.
S345 commit9
*ommit complete.
S345 commit9
*ommit complete.
S345 commit9
*ommit complete.
Table altered.
S345 7emctl start dbconsole T> set to Asia;*alcutta %racle nterprise !anager (:g #atabase *ontrol &elease (:.+.:.(.: *opyright ?c) (@@1, +::/ %racle *orporation. All rights reserved. httpA;;station.:.eBample.comA//:-;em;console;aboutApplication Starting %racle nterprise !anager (:g #atabase *ontrol ........................ started. 000000000000000000000000000000000000000000000000000000000000000000 4ogs are generated in directory ;u:(;app;oracle;product;(:.+.:;db<(;station.:.eBample.com<mydb;sysman;log
S345
Start nterprise !anager *lick on the Administration tab Go to the bottom of the page *lick on Advisor *entral 4ink *lick on Segment Advisor 'ollow the Steps to gather recommendations
--No of blocks consumed by the table before the shrink operation. S345 select table<name,blocks + from dba<tables - where table<name8C !,C . and owner8CD&C9
TAE4 <"A!
E4%*FS
Table altered.
--No of blocks consumed by the table after the shrink operation. S345 select table<name, + blocks
Gou can note that the number of blocks have reduced incredibly after the shrink operation.