当前位置:文档之家› db2培训(7)数据迁移专题复习进程

db2培训(7)数据迁移专题复习进程

• Coldel • Chardel
IMPORT 和 LOAD 对比
IMPORT
• 导入大数据时慢 • 可通过IXF格式创建表 • 所有行都记日志
• 会触发触发器,约束等
LOAD
• 处理大数据量时速度快
• Load前,表和索引必须存在
• 已有的数据仍然可读 • 记很少的日志; can make copy
LOBS FROM
, lob-path
MODIFIED BY
filetype-mod
... ALLOW NO ACCESS ALLOW WRITE ACCESS
COMMITCOUNT n/
RESTARTCOUNT n
Automatic
MESSAGES message-file
INSERT INSERT_UPDATE REPLACE REPLACE_CREATE
calpar.del
10 ~ ~ 1 20 ~ ~ 30 ~ ~ 3 30 ~ ~ 4 40 ~ ~ X 50 ~ ~ 6 50 ~ ~ 7 80 ~ ~ 8
cal.par
10 ~ ~ 1 30 ~ ~ 3 50 ~ ~ 6 80 ~ ~ 8
Prim ary Key
Ta b le
IMPORT 例子
• 将文件数据导入到表中
db2 connect to musicdb
db2 import from artexprt of ixf
messages artmsg
create insert insert_update replace replace_create
into artists
ALLOW NO ACCESS
| statistics options | |copy options|
ALLOW READ ACCESS USE tablespace-name
| set integrity pending options |
LOCK WITH FORCE
LOAD 典型场景
IN P U T
INSERT 语句
• INSERT语句:
– 有overhead,需要通过引擎,验证RI,Check,唯一性约束, 执行trigger
– 插入操作发生时,需要记日志
• 在处理大数据量方面,INSERT可能不是最快的,也不是最好的
办法
• insert into artists (artno, name,
db2 connect to musicdb db2 import from artexprt of ixf
messages artmsg insert into artists
artexprt
IMPORT
DB2
musicdb
artists
IMPORT 大对象处理 • CLOB
IMPORT modified by修饰符
db2培训(7)数据迁移 专题
数据迁移方法
• 同平台,不同机器
– 备份/恢复
• 不同平台数据库间
– Export/import/load/db2move等 – Load from cursor
• 同数据库不同表
– Insert … select – Export/import/load
• 库不可连接
INTO
CREATE INTO table-name
table-name (
, insert-column )
, ( insert-column )
| tblspace-specs |
tblspace-specs
|
|
IN tablespace-name
INDEX IN tablespace-name LONG IN tablespace-name
classification) values (100, 'Patti & Cart Wheels', 'S')
• Insert into emptemp select * from employee
IMPORT 命令语法(Basic)
IMPORT FROM filename OF filetype
• 不会触发trigger,RI和check约
束在set integrity阶段验证;会 验证唯一性约束
Load 过程的4个阶段
1. LOAD
Load data into tables
DB2 Data
C ollect index keys / sort
C onsistency points at SAVEC O U N T
filetype-mod
SAVECOUNT n
ROWCOUNT n
WARNINGCOUNT n
MESSAGES msg-file
...
INSERT REPLACE RESTART TERMINATE
INTO table-name
, ( insert-column )
FOR EXCEPTION table-name
– db2dart
数据导入导出工具一览
DEL格式
• 文本格式 • 每行代表一条记录 • 字段之间用分隔符分隔,如,;!等 • 某字段字符串用符号包围,如‘’,“”等
非DEL的ACSII格式
• 文本格式 • 每行代表一条记录 • 字段是定长表示,不足用空格补齐
PC/IXF格式
• PC/IXF格式是IBM特有的二进制格式 • 用于在异构平台间导入导出数据 • 可包含表的类型和定义 • db2move支持的格式
Invalid data row s in dum p file; m essages in m essage file
2. BUILD Indexes created or updated
3. DELETE
U n iqu e K e y V io lation s p la ced in E xce ption Ta ble M essages generated for unique key violations D eletes U nique Key Violation R ow s
4. INDEX CO PY
C opy indexes from tem p table space to index table space
LOAD 命令语法(Basic)
LOAD
CLIENT
FROM
,
file pipe device cursorname
OF
ASC
DEL
பைடு நூலகம்
IXF
CURSOR
MODIFIED BY
相关主题