本文介绍了基于MySQL触发器的审计日志记录与比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

查看类似的问题:

我想再进一步并比较更新的数据,看看它是否真的被更新...我不知道这是否理想(性能明智)。

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

背景:

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

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.

谢谢!

推荐答案

您可以写一个 BEFORE UPDATE 触发器,其中使用 OLD NEW 触发器中的别名,以便将更新前记录中可用的值与要更新的值进行比较。根据比较结果,您可以将条目写入审计表。

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.

这篇关于基于MySQL触发器的审计日志记录与比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 21:53
查看更多