我在一张表中有两个时间戳。
1 - timestamp01
- 这将记录用户在数据库中创建新行时的时间戳
2 - timestamp02
- 当用户更新/编辑特定行中的任何内容时,这应该记录时间戳。
我的问题是,当用户对特定行进行某些更改时,如何设置 timestamp02
来记录当前时间戳?
我使用 MySQL 作为数据库
最佳答案
此链接应该对您有帮助 https://dev.mysql.com/doc/refman/5.5/en/timestamp-initialization.html 。因此,您必须将该列标记为自动更新,以跟踪行的所有更新
timestamp02 更新时的时间戳默认为 CURRENT_TIMESTAMP CURRENT_TIMESTAMP
但是,请注意文档所说的
One TIMESTAMP column in a table can have the current timestamp as the default value for initializing the column, as the auto-update value, or both. It is not possible to have the current timestamp be the default value for one column and the auto-update value for another column.
关于mysql - 管理两个时间戳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36687948/