在SQL Server中实现审计表的建议? [英] Suggestions for implementing audit tables in SQL Server?

查看:127
本文介绍了在SQL Server中实现审计表的建议?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

过去使用的一个简单方法基本上是创建第二个表,其结构映射我想要审计的表,然后在主表上创建一个更新/删除触发器。在更新/删除记录之前,当前状态通过触发器保存到审计表。

One simple method I've used in the past is basically just creating a second table whose structure mirrors the one I want to audit, and then create an update/delete trigger on the main table. Before a record is updated/deleted, the current state is saved to the audit table via the trigger.

审计表中的数据虽然有效,但不是最有用的或简单报告。我想知道是否有人有一个更好的方法来审计数据更改?

While effective, the data in the audit table is not the most useful or simple to report off of. I'm wondering if anyone has a better method for auditing data changes?

这些记录不应该有太多的更新,但它是高度敏感的信息,所以对客户来说重要的是,所有更改都经过审核并且容易报告。

There shouldn't be too many updates of these records, but it is highly sensitive information, so it is important to the customer that all changes are audited and easily reported on.

推荐答案

我使用了一个审计表,其中包含表,列,OldValue,NewValue,User和ChangeDateTime的列 - 通用的与DB中的任何其他更改一起工作,并且在将大量数据写入该表时,对该数据的报告稀疏到足以在一天的低使用期间运行。

I've used a single audit table, with columns for Table, Column, OldValue, NewValue, User, and ChangeDateTime - generic enough to work with any other changes in the DB, and while a LOT of data got written to that table, reports on that data were sparse enough that they could be run at low-use periods of the day.

已添加:
如果数据量与报表数量之间存在关系,则可将审计表复制到只读数据库服务器,以便运行在必要时报告,而不妨碍主服务器从事他们的工作。

Added: If the amount of data vs. reporting is a concern, the audit table could be replicated to a read-only database server, allowing you to run reports whenever necessary without bogging down the master server from doing their work.

这篇关于在SQL Server中实现审计表的建议?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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