DB2数据库中有一张分区表(包含主键索引和部分分区索引),在对某个分区做reorg时,其它分区是否可以select或者update? reorg的语句,如:db2 "reorg table wf_h_activityinst on datapartition P201701"
收起对于联机交易型系统,如果无法提供停机reorg窗口,在分区表设计阶段应该考虑将主键创建为分区索引。
默认情况下主键都是全局索引,可以先创建唯一性分区索引并且要包含分区键,然后添加主键,DB2自动会将这个唯一索引设置为主键约束。
感兴趣的可以测试下,如下命令供参考。
--创建唯一性索引
db2 \"create unique index idx_process_1 on process(id,dt) partitioned\" //必需包含分区键
--删除原来的主键
db2 \"alter table process drop primary key\"
--添加主键约束
db2 \"alter table process alter column dt set not null\" //主键所有列都是非空
db2 \"reorg table process\"
db2 \"alter table process add primary key (id,dt)\"
db2 describe indexes for table process //查看索引类型由U变为P
db2 \"reorg table process allow read access on data partition 20170101\" //reorg可以allow read access了