如何定义数据库审计规范' BY Any User'

时间:2018-01-03 12:06:16

标签: sql-server tsql sql-server-2012 audit

我想跟踪多个表上的插入更新和删除。我现在拥有的是

ALTER DATABASE AUDIT SPECIFICATION [mySpec]

ADD (INSERT ON OBJECT::[dbo].[SomeTable] BY [SomeUser]),
ADD (UPDATE ON OBJECT::[dbo].[SomeTable] BY [SomeUser]),
ADD (DELETE ON OBJECT::[dbo].[SomeTable] BY [SomeUser]),

... More Tables ..

WITH (STATE = ON);

是否有一组校长等于"任何用户"我可以使用而不是“SomeUser”#39;在我的剧本中?

1 个答案:

答案 0 :(得分:1)

您可以使用public群组

例如:

ALTER DATABASE AUDIT SPECIFICATION [mySpec]
ADD (INSERT ON OBJECT::[dbo].[SomeTable] BY [public])
...

或您所有用户所属的任何其他群组。

您还可以对要审核的事件进行分组,

ALTER DATABASE AUDIT SPECIFICATION [mySpec]
ADD (INSERT, UPDATE, DELETE ON OBJECT::[dbo].[SomeTable] BY [public])
...

如果要审核所有表,可以使用数据库对象

ALTER DATABASE AUDIT SPECIFICATION [mySpec]
ADD (INSERT, UPDATE, DELETE ON DATABASE::databasename BY [public])
...