问题描述
在mysql中,我有一个字段名称为added_on
的timestamp
.我创建该表的原因是crm.但是每当我更新潜在客户时,它就会被更新.我只希望时间戳仅显示添加的时间.我不希望每次更新或更改线索时都会更新该信息.
In mysql I have a timestamp
with the field name added_on
. I created that for a table of leads for a crm. But it's getting updated whenever I update a lead. I only want the timestamp to show only the added time. I dont want that to get updated everytime when I update or make changed in the lead.
注意:创建时间戳记字段时,我给了默认值作为时间戳记,创建字段后,它在Extras字段中显示了ON UPDATE CURRENT_TIMESTAMP
.
Note: while creating the timestamp field i gave default value as timestamp and it shows ON UPDATE CURRENT_TIMESTAMP
in the extras field after creating the field.
有什么想法可以在我更新行时停止更新时间戳吗?
any ideas to stop the timestamp getting updated whenever I update the row?
推荐答案
问题是ON UPDATE CURRENT_TIMESTAMP
.您应该可以使用这样的alter语句来取消此行为(不确定您的表名是什么):
The issue is the ON UPDATE CURRENT_TIMESTAMP
. You should be able to undo this behavior with an alter statement like this (not sure what your table name is):
ALTER TABLE leads MODIFY added_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
这篇关于时间戳,不更改更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!