修改记录时mysql时间戳更新

发布于 2024-09-17 23:32:16 字数 362 浏览 4 评论 0原文

我不久前提出了一个关于这个问题的问题,但我仍然有一个问题。我有一个 mysql5 数据库,其中有一个销售表,其中包含代表销售的时间戳。如果销售表中的某个字段被修改或更改,则时间戳会更新为当前时间(更改的时间)。为了防止这种情况,我取消选择了 on_update_select_current_timestamp 选项,但时间戳仍然发生变化?

这是 phpmyadmin 中该字段的外观

alt text

有谁知道我应该做什么,取消选中 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

alt text

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

倒带 2024-09-24 23:32:16

如果您不希望该字段自动更新,则根本不要使用时间戳类型字段
请改用日期时间。

if you don't want this field to be updated automatically, just do not use timestamp type field at all
Use datetime instead.

莫多说 2024-09-24 23:32:16

检查表定义,如果 CURRENT-TIMESTAMP 选项确实被禁用。

如果禁用,它应该看起来像...

CREATE TABLE `sometable` (
  ...somefields...
  `Sale_Time` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00' INT(11) DEFAULT NULL,
  ...somefields...
) ENGINE=someengine

...否则 CURRENT-TIMESTAMP 将在此行中可见。当它被禁用时,它不会在更新时更新,除非某些其他数据库功能(触发器等)在更新字段时更改它。

Check the table definitions, if the CURRENT-TIMESTAMP option is really disabled.

If its disabled, it should look like...

CREATE TABLE `sometable` (
  ...somefields...
  `Sale_Time` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00' INT(11) DEFAULT NULL,
  ...somefields...
) ENGINE=someengine

...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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文