insert into n values(15,'2004-10-21','23:12:23','abc','hh',35.2)
insert into n values(5,'2004-1-21','3:12:23','bc','hhh',35.672)
要想把这两条数据以规整的格式导出到文件中,进行如下操作:
export to c:\test.txt of del select char(a) ¦ ¦ char(b) ¦ ¦ char(c) ¦ ¦ char(d,5) ¦ ¦ e ¦ ¦ char(f) as tmp from n
export to d:\myfile.del of del lobs to d:\lob\ lobfile lobs modified by lobsinfile select * from emp_photo
该命令把emp_photo表的数据导出到d:\myfile.del文件中,其结果为:
"000130","bitmap","lobs.001.0.43690/"
"000130","gif","lobs.001.43690.29540/"
"000130","xwd","lobs.001.73230.45800/"
"000140","bitmap","lobs.001.119030.71798/"
"000140","gif","lobs.001.190828.29143/"
"000140","xwd","lobs.001.219971.73908/"
"000150","bitmap","lobs.001.293879.73438/"
"000150","gif","lobs.001.367317.39795/"
"000150","xwd","lobs.001.407112.75547/"
"000190","bitmap","lobs.001.482659.63542/"
"000190","gif","lobs.001.546201.36088/"
"000190","xwd","lobs.001.582289.65650/"
其中第三个字段是BLOB类型,在该文件中只保存了一个标志,相当于一个指针,真正的LOB数据保存在d:\lob目录下的lobs.001、lobs.002、......等一系列文件中。命令中lobs to 后面指定大对象数据保存在什么路径下(注意,该路径必须事先已经存在,否则会报错),lobfile 后面指定大对象数据保存在什么文件中,不要指定扩展名,DB2会根据数据量自动追加.001、.002等扩展名,同时不要忘记加上modified by lobsinfile子句。
例五:把导出信息保存在消息文件中。
export to d:\awards.ixf of ixf messages d:\msgs.txt select * from staff where dept = 20