时间戳,不更改更新 [英] Timestamp without change on update

查看:135
本文介绍了时间戳,不更改更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在mysql中,我有一个字段名称为added_ontimestamp.我创建该表的原因是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

这篇关于时间戳,不更改更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆