Reorg

Reorg

数据库里某个表中的记录变化量很大时,需要在表上做REORG操作来优化数据库性能。

值得注意的是,针对数据库对象的大量操作,如反复地删除表,存储过程,会引起系统表中数据的频繁改变,在这种情况下,也要考虑对系统表进行REORG操作。

一个完整的REORG表的过程应该是由下面的步骤组成的:

RUNSTATS -> REORGCHK -> REORG -> RUNSTATS -> BINDREBIND

 

 

 

 

reorg table

[db2inst1@test1 ~]$ db2 reorg table DB2INST1.ACT inplace allow write access      

 

 

生成脚本:

[db2inst1@test1 ~]$ cat reorg.sh

#!/bin/sh

echo 'date=`date  +%Y-%m-%d`'

echo 'time=`date +%H:%M:%S`'

echo 'echo $date'

echo 'echo $time'

echo 'db2 connect to sample'

db2 connect to sample > /dev/null

echo "#=======reorg table==="

db2 -x "select  'db2 reorg table '||rtrim(tabschema)||'.'||tabname||' inplace allow write access'  from  sysstat.tables where TABSCHEMA='DB2INST1' "

echo "#=======reorg index==="

db2 -x "select  'db2 reorg indexes all for table '||rtrim(tabschema)||'.'||tabname||' allow read access'  from  sysstat.tables where TABSCHEMA='DB2INST1' "

echo "#=======runstats==="

db2 -x "select  'db2 runstats on table '||rtrim(tabschema)||'.'||tabname||' with distribution and indexes all'  from  sysstat.tables where TABSCHEMA='DB2INST1' "



 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值