修改众多库表的索引的脚本
时间:2008-07-11 来源:starB6
db2 "connect to databasename user db2app using mypasswd"
while read test
do
echo $test
db2 "describe indexes for table SCOTT.IMAGE_$test "
db2 "drop index SCOTT.IMAGE_"$test"_1"
db2 "drop index SCOTT.IMAGE_"$test"_2"
db2 "drop index SCOTT.IMAGE_"$test"_3"
db2 "drop index SCOTT.IMAGE_"$test"_4"
db2 "drop index SCOTT.IMAGE_"$test"_5"
db2 "create index SCOTT.IMAGE_"$test"_1 on SCOTT.IMAGE_"$test" (DOCDATE ASC) PCTFREE 10"
db2 "RUNSTATS ON TABLE SCOTT.IMAGE_"$test" for INDEX SCOTT.IMAGE_"$test"_1 shrlevel reference"
db2 "create index SCOTT.IMAGE_"$test"_2 on SCOTT.IMAGE_"$test" (DOCID ASC) PCTFREE 10"
db2 "RUNSTATS ON TABLE SCOTT.IMAGE_"$test" for INDEX SCOTT.IMAGE_"$test"_2 shrlevel reference"
done < ADOC while read idx
do
echo $idx
db2 "describe indexes for table SCOTT.IMAGE_$idx "
db2 "drop index SCOTT.IMAGE_"$idx"_1"
db2 "drop index SCOTT.IMAGE_"$idx"_2"
db2 "drop index SCOTT.IMAGE_"$idx"_3"
db2 "drop index SCOTT.IMAGE_"$idx"_4"
db2 "drop index SCOTT.IMAGE_"$idx"_5"
db2 "create index SCOTT.IMAGE_"$idx"_1 on SCOTT.IMAGE_"$idx" (DOCDATE ASC) PCTFREE 10"
db2 "RUNSTATS ON TABLE SCOTT.IMAGE_"$idx" for INDEX SCOTT.IMAGE_"$idx"_1 shrlevel reference"
db2 "create index SCOTT.IMAGE_"$idx"_2 on SCOTT.IMAGE_"$idx" (DOCID ASC) PCTFREE 10"
db2 "RUNSTATS ON TABLE SCOTT.IMAGE_"$idx" for INDEX SCOTT.IMAGE_"$idx"_2 shrlevel reference"
db2 "create index SCOTT.IMAGE_"$idx"_3 on SCOTT.IMAGE_"$idx" (MOBILENO ASC) PCTFREE 10"
db2 "RUNSTATS ON TABLE SCOTT.IMAGE_"$idx" for INDEX SCOTT.IMAGE_"$idx"_3 shrlevel reference"
db2 "create index SCOTT.IMAGE_"$idx"_4 on SCOTT.IMAGE_"$idx" (VOLUMENO ASC) PCTFREE 10"
db2 "RUNSTATS ON TABLE SCOTT.IMAGE_"$idx" for INDEX SCOTT.IMAGE_"$idx"_4 shrlevel reference"
done < AIDX db2 "disconnect databasename "
while read test
do
echo $test
db2 "describe indexes for table SCOTT.IMAGE_$test "
db2 "drop index SCOTT.IMAGE_"$test"_1"
db2 "drop index SCOTT.IMAGE_"$test"_2"
db2 "drop index SCOTT.IMAGE_"$test"_3"
db2 "drop index SCOTT.IMAGE_"$test"_4"
db2 "drop index SCOTT.IMAGE_"$test"_5"
db2 "create index SCOTT.IMAGE_"$test"_1 on SCOTT.IMAGE_"$test" (DOCDATE ASC) PCTFREE 10"
db2 "RUNSTATS ON TABLE SCOTT.IMAGE_"$test" for INDEX SCOTT.IMAGE_"$test"_1 shrlevel reference"
db2 "create index SCOTT.IMAGE_"$test"_2 on SCOTT.IMAGE_"$test" (DOCID ASC) PCTFREE 10"
db2 "RUNSTATS ON TABLE SCOTT.IMAGE_"$test" for INDEX SCOTT.IMAGE_"$test"_2 shrlevel reference"
done < ADOC while read idx
do
echo $idx
db2 "describe indexes for table SCOTT.IMAGE_$idx "
db2 "drop index SCOTT.IMAGE_"$idx"_1"
db2 "drop index SCOTT.IMAGE_"$idx"_2"
db2 "drop index SCOTT.IMAGE_"$idx"_3"
db2 "drop index SCOTT.IMAGE_"$idx"_4"
db2 "drop index SCOTT.IMAGE_"$idx"_5"
db2 "create index SCOTT.IMAGE_"$idx"_1 on SCOTT.IMAGE_"$idx" (DOCDATE ASC) PCTFREE 10"
db2 "RUNSTATS ON TABLE SCOTT.IMAGE_"$idx" for INDEX SCOTT.IMAGE_"$idx"_1 shrlevel reference"
db2 "create index SCOTT.IMAGE_"$idx"_2 on SCOTT.IMAGE_"$idx" (DOCID ASC) PCTFREE 10"
db2 "RUNSTATS ON TABLE SCOTT.IMAGE_"$idx" for INDEX SCOTT.IMAGE_"$idx"_2 shrlevel reference"
db2 "create index SCOTT.IMAGE_"$idx"_3 on SCOTT.IMAGE_"$idx" (MOBILENO ASC) PCTFREE 10"
db2 "RUNSTATS ON TABLE SCOTT.IMAGE_"$idx" for INDEX SCOTT.IMAGE_"$idx"_3 shrlevel reference"
db2 "create index SCOTT.IMAGE_"$idx"_4 on SCOTT.IMAGE_"$idx" (VOLUMENO ASC) PCTFREE 10"
db2 "RUNSTATS ON TABLE SCOTT.IMAGE_"$idx" for INDEX SCOTT.IMAGE_"$idx"_4 shrlevel reference"
done < AIDX db2 "disconnect databasename "
相关阅读 更多 +