DB2中LOAD时处理不同日期格式的DATE列

问题描述:

DB2使用LOAD工具时,文件中日期格式为 MM/DD/YYYY,如何导入到DATE列?                                             
                

解决办法:

可以使用 MODIFIED BY dateformat关键字指定要导入数据文件中日期的格式。

$ db2level
DB21085I  This instance or install (instance name, where applicable: "e105q5a") 
uses "64" bits and DB2 code release "SQL10055" with level identifier 
"0606010E".
Informational tokens are "DB2 v10.5.0.5", "s141128", "IP23626", and Fix Pack 
"5".
Product is installed at "/opt/IBM/db2/V10.5.5".

$ db2 "create table t1(id int, birthday date)"
                                                                                                                       
$ cat t1.del                                                            
1,12/31/2015                                                            
2,03/22/2016                                                            
                                                             
$ db2 "load from t1.del of del MODIFIED BY dateformat=\"MM/DD/YYYY\" insert into t1"                                                         
                                                                                                                                                                                                                                        
$ db2 "select * from t1"

ID          BIRTHDAY  
----------- ----------
          1 2015-12-31
          2 2016-03-22

  2 record(s) selected.                              

参考资料:

LOAD命令

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值