gpt4 book ai didi

Mysql日期警告数据被截断

转载 作者:可可西里 更新时间:2023-11-01 06:41:53 24 4
gpt4 key购买 nike

我在使用 Mysql DATE 格式时遇到了一个有趣的问题。我有这张 table :

| id          | int(11)      | NO   | PRI | NULL    | auto_increment |
| file_path | varchar(255) | YES | | NULL | |
| date_export | date | YES | | NULL | |

当我使用日期函数 NOW() 更新一行时,日期将以这种格式更新:

'2014-01-23'

但是当我使用另一种日期格式时,比如手写格式:

update backup_conf_allied set date_export='2014-23-01' where file_path='IDF-952584-SW1' ;

date_export 列转换为:

'0000-00-00'

警告表告诉我:

| Warning | 1265 | Data truncated for column 'date_export' at row 3628 |

为什么?日期格式与 NOW() 函数相同。谢谢。

最佳答案

发布查询

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 Support DATE format as 'YYYY-MM-DD' , Year then Month then Date, 所以你用错误的值更新 Date 列 "2014-23-01",一年只有 12 个月,您使用的是无效的 23 月,MySQL 正在将其转换为零日期 (0000-00-00)

关于Mysql日期警告数据被截断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21305092/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com