Timestamp-type automatic update time when the record is updated in MySQL _ MySQL

Source: Internet
Author: User
In MySQL, when the record is updated, the timestamp type is automatically updated At bitsCN.com.

Timestamp-type automatic update time when the record is updated in MySQL

When I use navicat to set the date type to timestamp, I will find that IDE has one more option:



View the SQL statements automatically generated by IDE:

Write

'Lastupdate' timestamp not null default '2017-00-00 00:00:00 'on update CURRENT_TIMESTAMP

If this option is removed:

Write

'Lastupdate' timestamp not null default '2017-00-00 00:00:00'

The difference is "on update CURRENT_TIMESTAMP". its function is to automatically UPDATE the lastUpdate time to the current system time when there is a "change" in the record.

Note: The change is emphasized. In other words, this value will not be automatically updated even if the update statement is used but the content does not change.

BitsCN.com
Related Article

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.