Updating entry WITHOUT updating timestamp

前端 未结 5 473
旧时难觅i
旧时难觅i 2020-12-02 16:38

I have a timestamp in a mysql table with attribute \"ON UPDATE CURRENT_TIMESTAMP\". Is there a way to manually disable updating the timestamp on a special occasion? (eg: upd

5条回答
  •  难免孤独
    2020-12-02 17:11

    Is there a way to manually disable updating the timestamp on a special occasion? (eg: updating the entry to revise a blog post, but not to re-date it)

    Sounds like you need to configure the default constraint so that it populates the column on insertion only:

    DEFAULT CURRENT_TIMESTAMP
    

    Changing it to only be this means that any revisions will not trigger the timestamp value to be updated. IE: If you created the blogpost yesterday, and corrected a typo today - the date in the column would still be for yesterday.

提交回复
热议问题