MySQL is upgraded from 5.5 to 5.6, the TIMESTAMP changes, and 5.6 timestamp

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.