Automatically update MYSQL timestamp column even if there are no changes?

I have an update_date column in the table and type timestamp. I set the deault value using the phpmyadmin drop-down menu for CURRENT_TIMESTAMP. But later, when I run sql UPDATE x SET ... it updates the timestamp column only if there is a change in any of the columns. What I would like to achieve is whether there is a change or not set the current time every time sql update is performed. Is there a way to do this in mysql or do I need to set update_date explicitly every time an update is called?

thanks

+7
source share
1 answer

You need to explicitly update the column. From the MySQL manual TIMESTAMP Properties :

The TIMESTAMP auto-update column, if any, is automatically updated to the current timestamp when the value of any other column in the row changes from the current value. If all other columns are set to their current values, the TIMESTAMP column does not change. Automatic updating does not apply if the TIMESTAMP column is explicitly set to a value other than NULL.

Emphasis on mine.

+6
source

All Articles