Incorrect date value: '' for column 'Birthday' at row 1

某些版本数据库(5.0.41-community-nt)插入 date 类型的字段数据是 "" 空时,会报

Incorrect date value: '' for column 'Birthday' at row 1

类似这样的错误,只要先运行一下

SET SESSION sql_mode=NO_ZERO_IN_DATE;

就可以了

 

 

http://www.databasejournal.com/features/mysql/article.php/10897_3577131_2/Date-and-Time-in-MySQL-5.htm

 

Strict mode still permits zero dates though. To prohibit these, you can use the NO_ZERO_DATE (the entire date cannot be zero) or NO_ZERO_IN_DATE (no part of the date can be zero) modes. A convenient mode to use in this case is TRADITIONAL, which is equivalent to all of the STRICT_TRANS_TABLES, STRICT_ALL_TABLES, NO_ZERO_IN_DATE, NO_ZERO_DATE, ERROR_FOR_DIVISION_BY_ZERO and NO_AUTO_CREATE_USER modes.

相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页