修改记录时mysql时间戳更新
我不久前提出了一个关于这个问题的问题,但我仍然有一个问题。我有一个 mysql5 数据库,其中有一个销售表,其中包含代表销售的时间戳。如果销售表中的某个字段被修改或更改,则时间戳会更新为当前时间(更改的时间)。为了防止这种情况,我取消选择了 on_update_select_current_timestamp 选项,但时间戳仍然发生变化?
这是 phpmyadmin 中该字段的外观
有谁知道我应该做什么,取消选中 CURRENT_TIMESTAMP 选项似乎会重置on_update_select_current_timestamp 触发器
I raised a question about this a while ago but I'm still having an issue. I have a mysql5 database with a sales table that contains a timestamp to represent a sale. If a field in the sales table in amended or altered the timestamp updates to the current time (the time of the change). To prevent this I have unselected the on_update_select_current_timestamp option but still the timestamp changes?
Here's how the field looks in phpmyadmin
Does anyone have any idea what I should do, unchecking the CURRENT_TIMESTAMP option seems to reset the on_update_select_current_timestamp trigger
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您不希望该字段自动更新,则根本不要使用时间戳类型字段
请改用日期时间。
if you don't want this field to be updated automatically, just do not use timestamp type field at all
Use datetime instead.
检查表定义,如果
CURRENT-TIMESTAMP
选项确实被禁用。如果禁用,它应该看起来像...
...否则
CURRENT-TIMESTAMP
将在此行中可见。当它被禁用时,它不会在更新时更新,除非某些其他数据库功能(触发器等)在更新字段时更改它。Check the table definitions, if the
CURRENT-TIMESTAMP
option is really disabled.If its disabled, it should look like...
...otherwise the
CURRENT-TIMESTAMP
would be visible in this line. When it is disabled, it doesn't update on an update, unless some other database function (Trigger or such) changes it while updating fields.