Mysql日期警告数据被截断 [英] Mysql date warning data truncated
问题描述
我有这张表:
| id | int(11)| NO | PRI | NULL | auto_increment |
| file_path | varchar(255)|是| | NULL | |
| date_export |日期|是| | NULL | |
使用日期函数NOW()更新行时,这种格式:
'2014-01-23'
$ p $但是当我使用另一种日期格式,如手写的一样:
update backup_conf_allied set date_export ='2014-23-01'where file_path ='IDF-952584-SW1';
date_export列转换为:
'0000-00-00'
警告表告诉我:
|警告| 1265 |数据在行3628 |处截断了'date_export'列
为什么?日期格式与NOW()函数相同。
Thanks。解决方案发布的查询
update backup_conf_allied set`date_export ='2014-23-01'` where file_path ='IDF-952584-SW1';
应该是什么
update backup_conf_allied set`date_export ='2014-01-23'` where file_path ='IDF-952584-SW1';
MySQL支持DATE格式为'YYYY-MM-DD',
月份然后日期
,所以你正在更新日期列错误值2014年2月23日
,只有12个月,你正在使用月23,这是无效的,这是MySQL将其转换为ZERO DATE(0000-00-00)I'm having an interesting issue with Mysql DATE format. I have this table :
| id | int(11) | NO | PRI | NULL | auto_increment | | file_path | varchar(255) | YES | | NULL | | | date_export | date | YES | | NULL | |
When i'm updating a row using the date function : NOW(), the date is updated with this format :
'2014-01-23'
But when i'm using another date format, like hand-written one like :
update backup_conf_allied set date_export='2014-23-01' where file_path='IDF-952584-SW1' ;
The date_export column transforms into :
'0000-00-00'
Warning table tells me that :
| Warning | 1265 | Data truncated for column 'date_export' at row 3628 |
Why? The date format is the same as NOW() function. Thanks.
解决方案Posted query
update backup_conf_allied set `date_export='2014-23-01'` where file_path='IDF-952584-SW1' ;
What it should be
update backup_conf_allied set `date_export='2014-01-23'` where file_path='IDF-952584-SW1' ;
MySQL Support DATE format as 'YYYY-MM-DD' ,
Year then Month then Date
, So you are updating a Date column with wrong value"2014-23-01"
, There are only 12 months in year, you are using month 23 which is invalid that's MySQL is converting it to ZERO DATE (0000-00-00)这篇关于Mysql日期警告数据被截断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!