基于 MySQL 触发器的审计日志记录与比较

发布于 2024-07-19 06:39:10 字数 549 浏览 1 评论 0原文

在查看类似的问题时,例如:

获取触发器仅在审核表中插入更改的列值

审核日志记录策略

我想采用这个进一步比较更新的数据,看看它是否确实已更新......我不确定这是否理想(性能方面)。

背景:

我们有一些由用户定期更新的数据。

当这些数据更新时,我想将他们提交的内容与已有的内容以及他们提交的内容进行比较,以确保发生了变化。

如果发生更改,请继续将审核条目写入中央审核历史记录表,概述已更改的字段。

想法/想法? 我尽了最大努力进行搜索,但运气不佳。 如果这个问题重复,我会很乐意删除它。

谢谢!

In looking at similar questions like:

Getting trigger to insert changed column values only in audit table

Audit Logging Strategies

I would like to take this one step further and compare the updated data to see if it actually has been updated... I'm not sure if this is ideal (performance wise).

Background:

We have some data that is periodically updated by the user.

When this data is updated, I would like to compare what they submitted with what is already there and what they submitted, to make sure there has been a change.

If there has been a change, proceed to write an audit entry to the central audit history table outlining the fields changed.

Thoughts/ideas? I did my best to search but didn't have a lot of luck. I'll be happy to delete this question if it's a duplicate.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

泼猴你往哪里跑 2024-07-26 06:39:10

您可以编写一个 BEFORE UPDATE 触发器,在触发器中使用 OLDNEW 别名来比较之前记录中可用的值使用您正在更新的值进行更新。 根据比较结果,您可以将条目写入审核表。

You could write a BEFORE UPDATE trigger where you use the OLD and NEW aliases in your trigger to compare the values that were available in the record before the update with the values you are updating with. Depending on the result of the comparison you can write an entry to your audit table.

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