MySQL's current_timestamp pitfallReport an error
The answers on the Internet are basically as follows, but there is no specific solution The reason for the solution is that when you set a timestamp to on updatecurrent_timestamp, other timestamp fields need to explicitly set default values But if you have two timestamp fields, but only set the first one to current_timestamp and the second one has no default value, MySQL can successfully create the table, but not the other way around... My SolutionUninstall the current lower version of MySQL and install MySQL version 5.6 or higher. MySQL version 5.7 is recommended as it is relatively stable. mysql5.5.23 current_timestamp problemToday I created a new table with two fields: creation time and update time. Both default values are the current time. An error occurs when executing SQL.
I have used this SQL in other projects and it works fine. Why can't it be executed successfully today? After confirming that there were no syntax errors in the sql, I checked the information online. It turns out that MySQL 5.5 only supports one time field in a table using CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP. But in 5.6 it supports multiple. Original description
SolutionRemove the default creation time Check the MySQL version number using the status command The above is my personal experience. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. You may also be interested in:
|
>>: CSS animation combined with SVG to create energy flow effect
This article uses an example to describe how MySQ...
Table of contents How to set cookies Disadvantage...
Mysql supports 3 types of lock structures Table-l...
This article example shares the specific code of ...
This article uses examples to illustrate the prin...
Deleting a table is not very common, especially f...
WeChat Mini Programs are becoming more and more p...
1. Write a simple Java program public class tests...
<br />This section introduces how to impleme...
Table of contents 1. Basic configuration of Nginx...
VMWare (Virtual Machine ware) is a "virtual ...
For various reasons, sometimes you need to modify...
1.Write in front: As a lightweight virtualization...
Features of MySQL: MySQL is a relational database...
We know that when using HTML on NetEase Blog, we ...