您的位置:首页 > 产品设计 > UI/UE

ERROR 1292 (22007): Incorrect datetime value: '' for column 'end_date' at row 1

2017-07-05 22:14 1246 查看
mysql使用load data infile出现如下错误:

root@NoName 21:35:44> load data infile '/company.csv'  into table  company CHARACTER SET utf8 fields terminated by ',' optionally enclosed by '"' escaped by '"' 

    -> (src_company_id,company_name,province,start_date,econ_kind,oper_name,raw_regist_capi,regist_capi,

regist_capi_desc,cur_type,regist_no,credit_code,org_no,address,scope,term_start,term_end,belong_org,

check_date,end_date,status,is_listed,is_NEEQ,is_expired,main_category,big_category,src_created_date,

src_updated_date)

    -> ;
ERROR 1292 (22007): Incorrect datetime value: '' for column 'end_date' at row 1

这里的原因在于,end_date这个字段在csv文件中是空值。如果表中对应的字段允许为空的话,就可以按照下面的方式处理:注意上色的。

load data infile '/company.csv'  into table  company CHARACTER SET utf8 fields terminated by ',' optionally enclosed by '"' escaped by '"' 

(src_company_id,company_name,province,start_date,econ_kind,oper_name,raw_regist_capi,regist_capi,

regist_capi_desc,cur_type,regist_no,credit_code,org_no,address,scope,term_start,term_end,belong_org,

check_date,@end_date1,status,is_listed,is_NEEQ,is_expired,main_category,big_category,

src_created_date,src_updated_date)

set end_date=if(@end_date1='',NULL,  @end_date1);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐