MySQL is not allowing ON UPDATE CURRENT_TIMESTAMP for a DATETIME field

后端 未结 7 1625
不知归路
不知归路 2021-02-12 23:18

I have seen a lot of related questions, but I cannot place my finger on this specific question:

I have a MySQL table with both a TIMESTAMP (for when the field was create

7条回答
  •  抹茶落季
    2021-02-13 00:10

    DATETIME cannot use CURRENT_TIMESTAMP on update. Instead, change it to a TIMESTAMP.

    Or, consider using a trigger for this situation: http://dev.mysql.com/doc/refman/5.0/en/trigger-syntax.html

    EDIT: As in the comments (thanks @АлександрФишер!), this is no longer the case since MySQL 5.6.5, so another solution is to upgrade your server if possible.

提交回复
热议问题