gpt4 book ai didi

php - 如何不更新时间戳字段

转载 作者:行者123 更新时间:2023-11-29 04:30:36 25 4
gpt4 key购买 nike

项目是用php写的。
mysql 中有时间戳字段,它会自动更新。在一种情况下,我不需要更新此字段。我可以在没有获取时间戳值的情况下给出不更新此查询中的此字段的指令吗?

最佳答案

您应该将其更改为 DEFAULT CURRENT_TIMESTAMP 否则它将自动更新。来自manual :

In a CREATE TABLE statement, the first TIMESTAMP column can be declared in any of the following ways:

With both DEFAULT CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP clauses, the column has the current timestamp for its default value, and is automatically updated.

With neither DEFAULT nor ON UPDATE clauses, it is the same as DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP.

With a DEFAULT CURRENT_TIMESTAMP clause and no ON UPDATE clause, the column has the current timestamp for its default value but is not automatically updated.

关于php - 如何不更新时间戳字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3032597/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com