欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

DB2 数据库创建、表的ixf文件导出导入示例

程序员文章站 2022-06-17 19:28:54
1.创建数据库[db2inst1@localhost ~]$ db2set db2codepage=1208 #设置编码[db2inst1@localhost ~]$ db2 create datab...

1.创建数据库

[db2inst1@localhost ~]$ db2set db2codepage=1208 #设置编码

[db2inst1@localhost ~]$ db2 create database wms automatic storage yes using codeset utf-8territory cn pagesize 32768 #创建wms数据库

//指定db2数据库安装目录

db2 create db xxdb on /app/dbdata using codepage "gbk" country "zh_cn"

2.导出表的ixf文件(如:exportreportdata.sh)

todir=/home/cpsinst/bup/

tab="unteck_attachment_his unteck_busi_log unteck_dict_entry unteck_dict_type unteck_login_log unteck_menu unteck_operation unteck_organization unteck_primarykey unteck_resource unteck_role unteck_role_resource unteck_user unteck_user_role"

db2 connect to cpsdb

db2 set schema='odsuser'
for tabtemp in $tab
do

echo $tabtemp

db2 "export to ${todir}/${tabtemp}.ixf of ixf select * from ${tabtemp}"

done

3. 导入表的ixf文件

db2 connect to myetldb;
db2 set schema=odsuser;
db2 import from etl_busi_type.ixf of ixf modified by forcecreate commitcount 10000 replace_create into etl_busi_type
db2 import from etl_busi_type_tosend.ixf of ixf modified by forcecreate commitcount 10000 replace_create into etl_busi_type_tosend
db2 import from etl_contact_pepole.ixf of ixf modified by forcecreate commitcount 10000 replace_create into etl_contact_pepole