db2 export情况汇总
一、获取源表与目标表的表结构
1.分别登录原表、目标表所在的服务器
2.分别进入指定的实例
3.分别连接源表与目标表所在的服务器
4.db2 describe table Source_table;
db2 describe table Target_table;
一.源表与目标表表结构相同
export to /file path/Target_table.del of del messages /file path/Target_table.msg select * from tabname;
二.源表与目标表的表结构不同
1.字段顺序不同
Source_table
Column name schema Data type name Length Scale Nulls
------------------------------- --------- ------------------- ---------- ----- ------
PRD_CTG_KEY SYSIBM INTEGER 4 0 No
OM_BRAND_CD SYSIBM CHARACTER 8 0 No
PRD_CTG_CD SYSIBM CHARACTER 8 0 No
RPT_BRAND_CD SYSIBM VARCHAR 20 0 No
RPT_BRAND_SUBGROUP SYSIBM VARCHAR 20 0 No
5 record(s) selected.
Target_table
Column name schema Data type name Length Scale Nulls
------------------------------- --------- ------------------- ---------- ----- ------
PRD_CTG_KEY SYSIBM INTEGER 4 0 No
PRD_CTG_CD SYSIBM CHARACTER 8 0 No
OM_BRAND_CD SYSIBM CHARACTER 8 0 No
RPT_BRAND_CD SYSIBM VARCHAR 20 0 No
RPT_BRAND_SUBGROUP SYSIBM VARCHAR 20 0 No
5 record(s) selected.
解决方案:按照目标表的字段顺序导出
export to /file path/Target_table.del of del messages /file path/Target_table.msg
select PRD_CTG_KEY,PRD_CTG_CD,OM_BRAND_CD,RPT_BRAND_CD,RPT_BRAND_SUBGROUP from Source_table;
2.源表字段比目标表多
Source_table
Column name schema Data type name Length Scale Nulls
------------------------------- --------- ------