DB Audit Trail 的最佳实现是什么?

2021-11-30 00:00:00 sql-server audit

数据库审计跟踪记录用户上次修改、修改日期和创建日期.

有几种可能的实现方式:

  • SQL Server 触发器
  • 向数据库添加 UserModified、ModifiedDate、CreatedDate 列,并相应地在存储过程或插入、更新语句中包含逻辑.

如果您在答案中包含实现(或链接到),那就太好了.

解决方案

根据您在做什么,您可能希望将审计从数据层移到数据访问层.它为您提供更多控制权.

我在 NHibernate 和 SqlServer 这里问了一个类似的问题.>

A DB Audit Trail captures the User Last Modified, Modified Date, and Created Date.

There are several possible implementations:

  • SQL Server Triggers
  • Add UserModified, ModifiedDate, CreatedDate columns to the database and include logic in Stored Procedures or Insert, Update statements accordingly.

It would be nice if you include implementation (or link to) in your answer.

解决方案

Depending on what you're doing, you might want to move the audit out of the data layer into the data access layer. It give you more control.

I asked a similar question wrt NHibernate and SqlServer here.

相关文章