REM REM DBAToolZ NOTE: REM This script was obtained from DBAToolZ.com REM It's configured to work with SQL Directory (SQLDIR). REM SQLDIR is a utility that allows easy organization and REM execution of SQL*Plus scripts using user-friendly menu. REM Visit DBAToolZ.com for more details and free SQL scripts. REM REM REM File: REM c_ind_rebuild.sql REM REM INDX SEGMENT MOST REM REM Author: REM Vitaliy Mogilevskiy REM VMOGILEV REM (vit100gain@earthlink.net) REM REM Purpose: REM REM This script will rebuild indexes of your choice REM REM REM Usage: REM c_ind_rebuild.sql REM REM Example: REM c_ind_rebuild.sql REM REM REM History: REM 08-01-2001 VMOGILEV Created REM REM set trimspool on set pages 0 set feedback off set echo off set verify off prompt +-------------------------------------------------+ prompt | This script will rebuild indexes of your choice | prompt +-------------------------------------------------+ prompt accept owner prompt "Enter Index Owner [Enter For All]:" accept ind_name prompt "Enter Index Name [Enter For All]:" accept tab_name prompt "Enter Table Name [Enter For All]:" accept init_ext prompt "Enter Initial Extent size [Enter For the current one]: " accept next_ext prompt "Enter Next Extent size [Enter For the current one]: " accept pct_incr prompt "Enter % Increase [Enter For the current one]: " accept tabspace prompt "Enter Index Tablespace Name [Enter For the current one]: " accept curr_tabspace prompt "Enter Current Tablespace Name to Move From [Enter if it is doesn't matter]: " set term off SELECT 'PROMPT rebuilding index: '||owner||'.'||index_name||' tablespace: '||NVL('&&tabspace',tablespace_name)||' ... ALTER INDEX '||owner||'.'||index_name||' REBUILD TABLESPACE '||NVL('&tabspace',tablespace_name)||' STORAGE (INITIAL '||NVL('&init_ext',initial_extent)||' NEXT '||NVL('&next_ext',next_extent)||' PCTINCREASE '||NVL('&pct_incr',pct_increase)||' ) ONLINE;' FROM dba_indexes WHERE DECODE('&&owner',NULL,'1',owner) = NVL(upper('&&owner'),'1') AND DECODE('&&ind_name',NULL,'2',index_name) like NVL(upper('&&ind_name'),'2') AND DECODE('&&tab_name',NULL,'2',table_name) like NVL(upper('&&tab_name'),'2') AND DECODE('&&curr_tabspace',NULL,'3',tablespace_name) = NVL(upper('&&curr_tabspace'),'3') AND owner != 'SYS' AND owner != 'SYSTEM' AND partitioned != 'YES' spool reb_index.tmp / spool off set feedback on set term on ed reb_index.tmp