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
When building a B/S system interface, you often en...
Preface: Use debugbar to view document code in iet...
I recently took over a small program project, and...
Table of contents Installation Steps Environment ...
Table of contents 1. Get the file extension 2. Co...
(?i) means do not match case. Replace all uppercas...
Table of contents Vue.js 1. Register global guard...
Table of contents Scenario Core Issues Status mon...
This article shares the specific code of JavaScri...
Preface I have installed MySQL 5.6 before. Three ...
Table of contents Controller type of k8s Relation...
1. Modify the firewall settings and open the corr...
View the IP address of the Container docker inspe...
When using SQL to extract data, we often encounte...