
Questo script consente la ricostruzione di tutti gli indici di una particolare istanza e/o schema:
la sintassi corretta sarà:
./rebuilder.sh SID <schema>
#!/bin/sh
#rebuilder script
#trova indici e ricostruisce
#Tempesta Piergiorgio
read -p “Enter SYSTEM password: ” pass
if [ “$1” = “” ]; then
echo “\$1 is not set, syntax: rebuildIndex.sh sid ”
echo “sid =” $ORACLE_SID “All_index will be rebuild”
else
export ORACLE_SID=$1
fi
if [ “$2” = “” ]; then
echo “\$2 is not set: Rebuild for ALL index started…”
sqlplus -s /nolog < allIndex2.sql
/bin/sed /———–/d allIndex2.sql > IndexRebuild.sql
else
sqlplus -s /nolog < allIndex2.sql
/bin/sed /———–/d allIndex2.sql > IndexRebuild.sql
fi
echo “script IndexRebuid.sql successfully created”read -r -p “Exec IndexRebuild.sql? [Y/n]” response
case “$response” in
[yY][eE][sS]|[yY])
sqlplus -s /nolog <<EOF
connect SYSTEM/$pass
spool on
spool risultato.out
select to_char(sysdate,’DD/MM/YYYY HH24:MI:SS’) from dual;
@IndexRebuild.sql
select to_char(sysdate,’DD/MM/YYYY HH24:MI:SS’) from dual;
spool off
EOF
;;
*)
exit 0
esac
rm allIndex.sql
rm allIndex2.sql
rm on.lst
exit 0