当前位置:   article > 正文

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

invalid datetime format: 1292 incorrect datetime value: ''.

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);

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/607170
推荐阅读
相关标签
  

闽ICP备14008679号