当前位置:网站首页>ERROR 1067 (42000): Invalid default value for ‘end_ time‘ Mysql
ERROR 1067 (42000): Invalid default value for ‘end_ time‘ Mysql
2022-06-28 23:22:00 【waiting971118】
1、 Error message
After performing the following Sql When the sentence is , Error message :ERROR 1067 (42000): Invalid default value for ‘end_time’
CREATE TABLE seckill1(
`seckill_id` BIGINT NOT NULL AUTO_INCREMENT COMMENT ' inventory id',
`name` varchar(120) NOT NULL COMMENT ' Name of commodity ',
`number` int NOT NULL COMMENT ' Inventory quantity ',
`start_time` timestamp NOT NULL COMMENT ' Second kill start time ',
`end_time` timestamp NOT NULL COMMENT ' End time of seckill ',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ' Creation time ',
PRIMARY KEY(seckill_id),
key idx_start_time(start_time),
key idx_end_time(end_time),
key idx_create_time(create_time)
)ENGINE = InnoDB AUTO_INCREMENT = 1000 DEFAULT CHARSET = utf8 COMMENT = ' Second kill inventory watch '; The error message is as follows :
2、 Solution
(1) see sql_mode :
show session variables like '%sql_mode%(2) modify sql_mode( Get rid of NO_ZERO_IN_DATE,NO_ZERO_DATE) :
set sql_mode='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';(3) Re execution 1 Medium sql sentence :
Show that the table was created successfully
The screenshot of the three-step implementation is as follows :
3、 Reasons for error reporting
(1) Error explanation
The first one in the list TIMESTAMP Column ( namely 1 Of sql Statement start_time That's ok )( If it is not declared NULL Or display DEFAULT or ON UPDATE Clause ) Will automatically assign DEFAULT CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP attribute .
After the first TIMESTAMP Column ( namely 1 Of sql Statement end_time That's ok ) If it is not declared NULL Or display DEFAULT Clause ) Will automatically assign DEFAULT ‘0000-00-00 00:00:00’( Zero time stamp ), It's not enough sql_mode Medium NO_ZERO_DATE And report wrong .
(2) resolvent ( Three ) notes :2 The solution in is only for the created table
Method 1 : Execute first select @@sql_mode, Copy the value of the query and put NO_ZERO_DATE Delete , And then execute set sql_mode = ' Modified value '. This method only works in the current session
Method 2 : Execute first select @@global.sql_mode, Copy the value of the query and put NO_ZERO_DATE Delete , And then execute set global sql_mode = ' Modified value ', This method works in the current service , again MySQL Failure after service
Method 3 : stay mysql Installation directory , open my.ini or my.cnf file , Add the following line ,
sql_mode = ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION, And then restart mysql. This method works forever
边栏推荐
- Hesitating root sound
- Association line exploration, how to connect the two nodes of the flow chart
- Didn't find an internship. He summed it up
- Chapter V virtual memory exercise
- TDD and automated testing
- 【状态机设计】Moore、Mealy状态机、三段式、二段式、一段式状态机书写规范
- 股票开户在网上开通安全吗?
- Master the usage of const
- Keil project, RTT cannot print after too many programs are written
- 全面掌握const的用法《一》
猜你喜欢
![LeetCode 324 摆动排序 II[排序 双指针] HERODING的LeetCode之路](/img/41/b8ba8d771b7224eac1cc8c54fe9d29.png)
LeetCode 324 摆动排序 II[排序 双指针] HERODING的LeetCode之路

keil工程,程序写多后,RTT不能打印

【Word 教程系列第 2 篇】Word 中如何设置每页的表格都有表头

第三章 处理机调度练习
![[mathematical modeling] fmincon() function of MATLAB nonlinear programming](/img/fc/46949679859b1369fcc83d0d8b637c.png)
[mathematical modeling] fmincon() function of MATLAB nonlinear programming

【状态机设计】Moore、Mealy状态机、三段式、二段式、一段式状态机书写规范
![[数学建模]Matlab非线性规划之fmincon()函数](/img/fc/46949679859b1369fcc83d0d8b637c.png)
[数学建模]Matlab非线性规划之fmincon()函数

【Word 教程系列第 1 篇】如何去除 Word 表格中的箭头

华为22级专家十年心血终成云原生服务网格进阶实战文档,是真的6

mysql-5.7.30-winx64免安装版下载安装教程
随机推荐
Machine learning 4-dimension reduction technology
2022 PMP project management examination agile knowledge points (4)
百度知道爬虫,根据问题id,线索id,评论id获取评论下面的对话
关联线探究,如何连接流程图的两个节点
scrapy保存数据到excel:利用openpyxl创建多张表,设置Excel行数限制
keil工程,程序写多后,RTT不能打印
Use conditional breakpoints in vscode (based on GDB)
I can't sleep
Web API learning notes 1
Oil monkey script learning
图片64base转码与解码
LeetCode 324 擺動排序 II[排序 雙指針] HERODING的LeetCode之路
[matlab]函数定义与使用
TDD和自动化测试
C interview questions_ 20220627 record
Three communication skills in software testing
See fengzhixia | FENGZikai, the originator of Guoman, for exclusive sale of Digital Collections
CIN at QT (the clearest tutorial in the whole network)
Chapter II Classic synchronous exercises
在DialogFragment的onStop(完全不可见)时调用dismiss退出界面报错解决办法