timestamp Invalid default value

简介:

timestamp 默认值 '0000-00-00 00:00:00' ERROR 1067 (42000): Invalid default value for 'XXX'

例如

`created_time` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '插入时间',

解决方法

SET GLOBAL sql_mode='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
FLUSH PRIVILEGES;-- 立即生效

原因是 select @@sql_mode 查看 NO_ZERO_IN_DATE,NO_ZERO_DATE,去掉

ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
相关文章
使用result类一定要添加@Data注解“timestamp“:“2023-09-07T07:57:57.497+00:00““status“: 406,No acceptable repre
使用result类一定要添加@Data注解“timestamp“:“2023-09-07T07:57:57.497+00:00““status“: 406,No acceptable repre
Property ‘Authorization‘ does not exist on type ‘HeadersDefaults‘
Property ‘Authorization‘ does not exist on type ‘HeadersDefaults‘
88 0
|
6月前
|
JavaScript API
Property ‘proxy‘ does not exist on type ‘ComponentInternalInstance | null‘.ts
Property ‘proxy‘ does not exist on type ‘ComponentInternalInstance | null‘.ts
错误代码: 1364 Field ‘password‘ doesn‘t have a default value
错误代码: 1364 Field ‘password‘ doesn‘t have a default value
|
数据库
Field ‘id‘ doesn‘t have a default value
Field ‘id‘ doesn‘t have a default value
171 0
|
安全 JavaScript
TS中的unknown类型
TS中的unknown类型
185 0
|
SQL 关系型数据库 MySQL
Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT
Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT