import和export使用
- 增加数据
Import from aaa.del of del messages msg.out insert into product
Import from aaa.del of del messages msgout insert into product(price,prod_no,description)
2. 更新已经存在的数据及加入新数据
Import from aaa.del of del messages msg.out replace into product
3. 替换数据
Import from aaa.del of del messages msg.outreplace_create into product
4. 创建表
Import from aaa.ixf of ixf messages msg.outreplace_create into product
5. commitcount与restartcount选项
import from myfile.ixf of ixfcommitcount 500 messages msg.out insert into newtable
import from myfile.ixf of ixfcommitcount 50 restartcount 2000 messages msg.out insert into newtable
6. 导入大对象
例一:Export to myname.del of del select * from myname
格式:export to x.ixf of ixf … select * from X…
例二
db2 export to org.del of del modified by chardel! coldel@ codepage=1208 select * from org
字符串由感叹号!括起来,列由@号定界,字符串被转换成代码页1208
例二
db2 export to org.del of del modified by chardel! coldel@ codepage=1208 messages msg.out select * from org
字符串由感叹号!括起来,列由@号定界,字符串被转换成代码页1208,添加message参数后,产生一个msg.out文件,捕获导出期间错误,警告和信息性消息。
例三
导出大对象
Export to file_name of file_type lobs to lobfile_directory,lobfile_directory_2,….
Lobfilelobfilename
Modified by lobsinfileselect_statment
有了lobsinfile修饰符,export实用程序就查找lobs to 子句中指定的目录,然后将lob数据放在那里。如果没有找到lobs to 子句,就将lob数据发送到当前工作目录。
例四
CONNECT TO SAMPLE;
EXPORT TO "E:/db2log/org.ixf" OF IXF METHOD N (DEPTNUMB, DEPTNAME) MESSAGES "E:/db2log/msg.out" SELECT * FROM ADMINISTRATOR.ORG;
CONNECT RESET;
例五
CONNECT TO SAMPLE;
EXPORT TO "E:/db2log/org1.ixf" OF IXF MESSAGES "E:/db2log/msg1.out" SELECT * FROM ADMINISTRATOR.ORG;
CONNECT RESET;