MySQL is upgraded from 5.5 to 5.6, the TIMESTAMP changes, and 5.6 timestamp
Preface
Some time ago, the system MySQL was upgraded from 5.5 to 5.6, and a large number of exceptions occurred. Most of the exceptions are caused by changes in TIMESTAMP behavior.
TIMESTAMP behavior in MySQL5.5
- The first timestamp not null field with no default value set is the implicit default value:
CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP
- The default value of timestamp not null is NOT set later. The default value is implicit:
0000-00-00 00:00:00
- When the timestamp not null field is inserted as NULL, the implicit default value is used:
CURRENT_TIMESTAMP
- Multiple CURRENT_TIMESTAMP default values are not supported
TIMESTAMP behavior in MySQL5.6
- Support multiple CURRENT_TIMESTAMP default values
- Compatible with 5.5 million behaviors and supports implicit default values
- Explicit_defaults_for_timestamp = 0
- MySQL5.6 I tested and installed uses this parameter by default. When started, the server will give a warning.
[Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use-explicit_defaults_for_timestamp server option (see documentation for more details ).
- You can remove the default implicit values.
- Explicit_defaults_for_timestamp = 1
Summary
- In MySQL5.5, the TIMESTAMP behavior is quite strange and may cause some implicit problems. For example, if a NULL value is input in the program
- In MySQL5.6, the TIMESTAMP behavior can be changed to normal, but there may be compatibility problems.
- The explicit_defaults_for_timestamp parameter will disappear in the future.
- We should not rely too much on the features of the database. These features will cause constraints on applications.
Reference: http://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html#sysvar_explicit_defaults_for_timestamp
This article is from: Gao Shuang | Coder. The original Article address is http://blog.csdn.net/ghsau/article/details/45625841. For more information, see.