使用SQLServer Audit来审计对特定表操作的SQL语句

1、创建SQL Server审计

USE master

GO

CREATE SERVER AUDIT ServerAudit

  TO FILE (FILEPATH = ‘D:\bak\Audit\’, MAXSIZE = 1 GB)–注意更改文件路径

  WITH (ON_FAILURE = CONTINUE);

GO

2、创建服务器审计规范

USE slxsina

GO

CREATE DATABASE AUDIT SPECIFICATION product_nostandard FOR SERVER AUDIT ServerAudit

ADD(UPDATE,INSERT,DELETE ON dbo.product_nostandard by dbo)

GO

3、激活SQL Server审计

USE master

GO

ALTER SERVER AUDIT ServerAudit

WITH (STATE=ON)

4、查看审计数据

SELECT event_time ,

        succeeded ,

        server_principal_name ,

        [object_name] ,

        [statement]

FROM sys.fn_get_audit_file(‘D:\bak\Audit\*’, NULL, NULL)

WHERE database_name = ‘slxsina’ ;

image

About 智足者富

http://chenpeng.info

发表评论

电子邮件地址不会被公开。 必填项已用*标注

您可以使用这些HTML标签和属性:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>