It may appear in the production environment, the project is online, but the Update Time field is not assigned, that is, the update time is still null each time the data is updated. In order to solve this problem, the update time is usually updated when the program updates the data. But after the online change process needs to be re-upgraded, very troublesome. You can now ensure that the updated time of the data is updated automatically each time you update the data by modifying the field of the update time.
The update time is automatically updated by executing the following SQL on an already built table:
ALTER TABLE checker_barcode MODIFY COLUMN update_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
One of the things to note is:
1, replace "Checker_barcode" with the name of the table you need to update, replace "Update_time" with the name of the field you need to update, and the rest of SQL will not change.
2. After executing this SQL, all the update_time values in the table are null, and update_time all become the current time.
3, when executing the UPDATE statement, if the data does not really change, the Update_time value is unchanged, only the data value changes, Update_time will become the current time.
MySQL field value auto update time