Db2 reorg pending state

Error

Operation not allowed for reason code “7” on table “IBMCONSOLE.T1”… SQLCODE=-668, SQLSTATE=57016, DRIVER=4.27.25

The table is in the reorg pending state. This can occur after an ALTER TABLE statement containing a REORG-recommended operation. refer

Why

Starting with Db2® Version 9.7, you can run an unlimited number of ALTER TABLE statements within a single unit of work. In most situations, after processing three units of work that include such operations, the REORG TABLE command must be run.

Starting with Db2 Version 10.5 Fix Pack 5, when the table is in a reorg pending state, the data type of a column can be altered only once before the REORG TABLE command must be run. This restriction applies whether the alter operation occurs in a single unit of work or across multiple units of work.

refer

连续三次set data type将会使该表进入reorg pending状态。其实每次set data type都是需要reorg的,换句话说就是Db2可以容忍你两次不reorg,第三次就必须了。

For example:

drop table t1;
create table t1(c1 int, c2 int, c3 int, c4 int);

alter table t1 alter c1 set data type varchar(10);
alter table t1 alter c3 set data type varchar(10);
alter table t1 alter c2 set data type varchar(10);

获取次数

SELECT NUM_REORG_REC_ALTERS from SYSIBMADM.ADMINTABINFO where tabname = 'T1';

其他会进入reorgpending状态的操作

如何判断一个表是否处于reorg pending
SELECT REORG_PENDING FROM SYSIBMADM.ADMINTABINFO where tabname = 'tabname'

ADMINTABINFO KC

如何解除
reorg table schema.tabname
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值