MySQL upgrades from 5.5 to 5.6, and changes in 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.
The behavior of TIMESTAMP in MySQL5.5 is the first implicit default value for the timestamp not null field with no default value set:
CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP is followed by the default value of timestamp not null. The default value is implicit:
0000-00-00 00:00:00 timestamp not null when the field is inserted NULL, the implicit default value is used:
CURRENT_TIMESTAMP does not support multiple CURRENT_TIMESTAMP default values TIMESTAMP actions in MySQL5.6 support multiple CURRENT_TIMESTAMP default values can be compatible with 5.5 behavior, supports implicit default values
Explicit_defaults_for_timestamp = 0 this parameter is used by default in MySQL5.6 I tested and installed. 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 implicit DEFAULT value.
Explicit_defaults_for_timestamp = 1 sum up the TIMESTAMP behavior in MySQL5.5 is quite strange and may cause some implicit problems. For example, if the NULL value MySQL5.6 is input in the program, the TIMESTAMP behavior can be changed to normal, but there will be compatibility issues. The explicit_defaults_for_timestamp parameter will disappear in the future. We should not rely too much on database features. These features will cause constraints to applications.