您的位置:首页 > 数据库

将db2数据库某用户下的所有表进行数据统计分析

2013-10-28 19:13 423 查看
#!/bin/bash

####################################################################

#

# 将db2数据库某用户下的所有表进行数据统计分析

# 使用:修改tableSchema值和dbName值

#

####################################################################

tableSchema="DB2ECIF"

dbName="ecifdb"

db2 connect to $dbName > /dev/null

# 如果上一条命令执行后的结束代码不是0则执行下面的命令

if [ $? -ne 0 ]

then

echo "Failed to connect to database, please contact the administrator."

exit 1;

fi

db2 -x "SELECT TABNAME FROM SYSCAT.TABLES WHERE TABSCHEMA="$tableSchema" ORDER BY NPAGES DESC" >tables.list

for i in 0 1 2 3 4 5 6 7 8 9

do

echo "db2 connect to "$dbName";" >runstats$i.sh

chmod 755 runstats$i.sh

done

count=1

while read line

do

last_digit=`echo $count | sed 's/\(.*\)\(.\)$/\2/'`

echo "db2 runstats on table "$tableSchema".${line} on all columns with distribution and detailed indexes all;" >>runstats$last_digit.sh

count=`expr $count + 1`

done < tab.list

for i in 0 1 2 3 4 5 6 7 8 9

do

nohup ./runstats$i.sh >runstats$i.log &

done
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐