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
First, let’s think about a question: To insert su...
This article example shares the specific code of ...
When making forms, we often encounter the situati...
The default scroll bar style in Windows is ugly, ...
This article shares the specific code of typescri...
Background requirements: The ERP system needs to ...
I had nothing to do, so I bought the cheapest Ali...
Includes the process of initializing the root use...
The span tag is often used when making HTML web pa...
Docker supports running on the following CentOS v...
nginx (engine x) is a high-performance HTTP and r...
The cause is that the process opens a number of f...
Environment: CentOS 7.1.1503 Minimum Installation...
This article example shares the implementation me...
This article aims to use the clearest structure t...