Chinaunix首页 | 论坛 | 博客
  • 博客访问: 127880
  • 博文数量: 34
  • 博客积分: 1201
  • 博客等级: 少尉
  • 技术积分: 365
  • 用 户 组: 普通用户
  • 注册时间: 2010-10-21 08:56
文章分类

全部博文(34)

文章存档

2012年(1)

2011年(15)

2010年(18)

我的朋友

分类: 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' <#  ANALYZE INDEX $line VALIDATE STRUCTURE;
#  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;

阅读(898) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~