By default, MySQL can accept the insertion of 0 values in the date, but in reality, the 0 value in the date has no meaning. This can be achieved by adjusting the MySQL sql_mode variable. set @@global.sql_mode='STRICT_TRANS_TABLES,NO_ZERO_DATE,NO_ENGINE_SUBSTITUTION'; set @@session.sql_mode='STRICT_TRANS_TABLES,NO_ZERO_DATE,NO_ENGINE_SUBSTITUTION'; example: There is a table for logging create table app_logs( id int not null auto_increment primary key, log_tm timestamp not null, log_info varchar(64) not null) engine=innodb,charset=utf8; Insert interesting date values into the log table insert into app_logs(log_tm,log_info) values(now(),'log_info_1'); insert into app_logs(log_tm,log_info) values('2016-12-01','log_info_2'); Insert date values including 0 into the log table insert into app_logs(log_tm,log_info) values('2016-12-00','log_info_2'); ERROR 1292 (22007): Incorrect datetime value: '2016-12-00' for column 'log_tm' at row 1 The above article briefly discusses the problem of zero values in dates in MySQL database. This is all the content that the editor shares with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Native js to implement form validation function
>>: nginx configuration location summary location regular writing and rewrite rule writing
Analyze the production steps: 1. Prepare resource...
Table of contents 1. Software and system image 2....
Carousel animation can improve the appearance and...
Through an example, I shared with you the solutio...
MySQL executes SQL through the process of SQL par...
1. Background In actual projects, we will encount...
1. Promise description Promise is a standard buil...
xml <?xml version="1.0" encoding=&qu...
Table of contents 1. Basic conditions for databas...
Preface I am currently working on a high-quality ...
A WeakMap object is a collection of key/value pai...
1. Introduction The topic of whether to use forei...
Installing and deploying a private Docker Registr...
Preface PC Server has developed to this day and h...
Table of contents vue2.x Pre-concept: Routing hoo...