Simple SQL*Plus script for rebuild of indexes

In older versions of Oracle I sometimes faced problem of corupted or too fragmented indexes. In such case you need to rebuild them. But be careful this operation can be very time consuming and no one should work in database – if possible do it in restrict mode.

Here is very simple script for SQL*Plus which will do it:

set define off
set serveroutput on
spool rebuild_dsu.log
prompt Starting RE-BUILD of existing indexes

FOR INDEX_RECORD IN (select owner||'.'||object_name as obj
from dba_objects where object_type = 'INDEX' and owner ='...here_schema_name...')
execute immediate 'ALTER INDEX '||INDEX_RECORD.obj||' REBUILD';


Leave a Reply

Your email address will not be published. Required fields are marked *