分类: Oracle
2010-10-21 14:11:58
执行脚本文件index_segment.sh:
#!/bin/sh
# Oracle specific environment settings
export ORACLE_BASE=/ora01
export ORACLE_HOME=$ORACLE_BASE/9i
export ORACLE_SID=srm
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin:.
datadate=`date +%D`
datatime=`date +%R`
datapath=/backup/scrīpt/tunning/index_segment
data=index_segment.data-`date +%Y-%m`
sqlplus '/as sysdba' @$datapath/index_segment.sql
sqlplus '/as sysdba' <@$datapath/index_analyze_result.sql
SELECT NAME,(DEL_LF_ROWS_LEN/LF_ROWS_LEN) * 100 AS index_usage FROM index_stats;
exit;
!
#values=`/bin/cat $datapath/index_segment.log |egrep -v "SQL|Oracle|JServer|With|Disconnect|Connect|Total|-|rows"|sed '/^$/d'`
#values=`/bin/cat $datapath/index_segment.log |grep dbf|sed '/^$/d'`
#/bin/cat $datapath/index_segment.log |egrep -v "SQL|Oracle|JServer|With|Disconnect|Connect|Total|-"|sed '/^$/d' > $datapath/index.lst
#echo $datadate $datatime $values >> $datapath/$data
#cat index.lst |while read line
#do
# sqlplus '/as sysdba' <
# SELECT NAME,(DEL_LF_ROWS_LEN/LF_ROWS_LEN) * 100 AS index_usage FROM index_stats;
# exit;
# EOF1
#done
index_segment.sql:
set heading off;
set feedback off;
spool index_analyze_result.sql;
select 'ANALYZE INDEX '||index_name||' VALIDATE STRUCTURE; ' from dba_indexes where tablespace_name not like 'SYSTEM' and index_name not like 'SYS%' order by table_type,table_name;
spool off;
exit;