DB2数据迁移之load
DB2 数据迁移中 load 适合大数据量导入,因为它基本不写日志、不做检查约束和参照完整性约束、不触发 Trigger、锁时间短。load 过程分为 load/build/delete/index copy 四个阶段:load 阶段将源文件 parser 成物理存储格式直接装入页中(不经 db2 引擎),违背表定义的数据不会装入;build 阶段建立索引并检查唯一性约束,违背唯一性的数据在 delete 阶段被删除;index copy 仅适用于 allow read access 场景。缺省是 allow no access(offline load),allow read access(online load)只在 load …insert into 时可用,replace into 会先删数据只能离线加载。load 后表可能处于 load pending、set integrity pending、read access only 等状态,仅 normal 状态可正常增删改查。
文中通过 18 条记录的导入试验演示:先建目标表 xifenfei_load(含主键),再用 create table … like 建异常表并追加 ts、msg 列,执行 load from … of del modified by dumpfile=… insert into … for exception。结果显示 loaded 16、rejected 2、deleted 2,最终表中只有 14 条。其中 dumpfile 中记录了 2 条违背表定义(空值)被直接拒绝的记录,异常表中记录了 2 条违背唯一性约束、在建索引时被删除的记录,直观印证了 load 各阶段的检查行为。