ALTER DATABASE AUDIT SPECIFICATION (Transact-SQL)ALTER DATABASE AUDIT SPECIFICATION (Transact-SQL)

适用于:Applies to: 是SQL ServerSQL Server(所有支持的版本)yesSQL ServerSQL Server (all supported versions) 适用于:Applies to: 是SQL ServerSQL Server(所有支持的版本)yesSQL ServerSQL Server (all supported versions)

使用 SQL ServerSQL Server 审核功能更改数据库审核规范对象。Alters a database audit specification object using the SQL ServerSQL Server Audit feature. 有关详细信息,请参阅 SQL Server Audit(数据库引擎)For more information, see SQL Server Audit (Database Engine).

主题链接图标 Transact-SQL 语法约定Topic link icon Transact-SQL Syntax Conventions

语法Syntax

ALTER DATABASE AUDIT SPECIFICATION audit_specification_name  
{  
    [ FOR SERVER AUDIT audit_name ]  
    [ { { ADD | DROP } (   
           { <audit_action_specification> | audit_action_group_name }   
                )   
      } [, ...n] ]  
    [ WITH ( STATE = { ON | OFF } ) ]  
}  
[ ; ]  
<audit_action_specification>::=  
{  
      <action_specification>[ ,...n ] ON [ class :: ] securable   
     BY principal [ ,...n ]   
}  

备注

若要查看 SQL Server 2014 及更早版本的 Transact-SQL 语法,请参阅早期版本文档To view Transact-SQL syntax for SQL Server 2014 and earlier, see Previous versions documentation.

参数Arguments

audit_specification_name**audit_specification_name
审核规范的名称。The name of the audit specification.

audit_name**audit_name
应用此规范的审核的名称。The name of the audit to which this specification is applied.

audit_action_specification**audit_action_specification
一个或多个数据库级别可审核操作的名称。Name of one or more database-level auditable actions. 要获取审核操作组列表,请参阅 SQL Server 审核操作组和操作For a list of audit action groups, see SQL Server Audit Action Groups and Actions.

audit_action_group_name**audit_action_group_name
一个或多个数据库级别可审核操作组的名称。Name of one or more groups of database-level auditable actions. 要获取审核操作组列表,请参阅 SQL Server 审核操作组和操作For a list of audit action groups, see SQL Server Audit Action Groups and Actions.

classclass
安全对象上的类名(如果适用)。Class name (if applicable) on the securable.

securablesecurable
应用审核操作或审核操作组的数据库中的表、视图或其他安全对象。Table, view, or other securable object in the database on which to apply the audit action or audit action group. 有关详细信息,请参阅 SecurablesFor more information, see Securables.

columncolumn
安全对象上的列名(如果适用)。Column name (if applicable) on the securable.

principalprincipal
应用审核操作或审核操作组的 SQL ServerSQL Server 主体的名称。Name of SQL ServerSQL Server principal on which to apply the audit action or audit action group. 有关详细信息,请参阅主体(数据库引擎)For more information, see Principals (Database Engine).

WITH ( STATE = { ON | OFF } )************WITH ( STATE = { ON | OFF } )
允许或禁止审核收集此审核规范的记录。Enables or disables the audit from collecting records for this audit specification. 审核规范状态更改必须在用户事务之外进行,并且从 ON 转换到 OFF 时,审核规范的同一语句中不能有其他更改。Audit specification state changes must be done outside a user transaction and may not have other changes in the same statement when the transition is ON to OFF.

注解Remarks

数据库审核规范是驻留在给定数据库中的非安全对象。Database audit specifications are non-securable objects that reside in a given database. 必须将审核规范的状态设置为 OFF 选项,以便更改数据库审核规范。You must set the state of an audit specification to the OFF option in order to make changes to a database audit specification. 使用 STATE=OFF 以外的任何选项启用审核后,如果执行 ALTER DATABASE AUDIT SPECIFICATION,将接收到错误消息。If ALTER DATABASE AUDIT SPECIFICATION is executed when an audit is enabled with any options other than STATE=OFF, you will receive an error message. 有关详细信息,请参阅 tempdb DatabaseFor more information, see tempdb Database.

权限Permissions

具有 ALTER ANY DATABASE AUDIT 权限的用户可以更改数据库审核规范并将其绑定到任何审核。Users with the ALTER ANY DATABASE AUDIT permission can alter database audit specifications and bind them to any audit.

创建数据库审核规范后,具有 CONTROL SERVER 或 ALTER ANY DATABASE AUDIT 权限的主体、sysadmin 帐户或对审核具有明确访问权限的主体即可查看该规范。After a database audit specification is created, it can be viewed by principals with the CONTROL SERVER,or ALTER ANY DATABASE AUDIT permissions, the sysadmin account, or principals having explicit access to the audit.

示例Examples

下面的示例针对称为 HIPAA_Audit_DB_SpecificationSQL ServerSQL Server 审核更改称为 SELECT 的数据库审核规范,该规范审核 dbo 用户发出的 HIPAA_Audit 语句。The following example alters a database audit specification called HIPAA_Audit_DB_Specification that audits the SELECT statements by the dbo user, for a SQL ServerSQL Server audit called HIPAA_Audit.

ALTER DATABASE AUDIT SPECIFICATION HIPAA_Audit_DB_Specification  
FOR SERVER AUDIT HIPAA_Audit  
    ADD (SELECT  
         ON OBJECT::dbo.Table1  
         BY dbo)  
    WITH (STATE = ON);  
GO  

有关如何创建审核的完整示例,请参阅 SQL Server Audit(数据库引擎)For a full example about how to create an audit, see SQL Server Audit (Database Engine).

另请参阅See Also

CREATE SERVER AUDIT (Transact-SQL) CREATE SERVER AUDIT (Transact-SQL)
ALTER SERVER AUDIT (Transact-SQL) ALTER SERVER AUDIT (Transact-SQL)
DROP SERVER AUDIT (Transact-SQL) DROP SERVER AUDIT (Transact-SQL)
CREATE SERVER AUDIT SPECIFICATION (Transact-SQL) CREATE SERVER AUDIT SPECIFICATION (Transact-SQL)
ALTER SERVER AUDIT SPECIFICATION (Transact-SQL) ALTER SERVER AUDIT SPECIFICATION (Transact-SQL)
DROP SERVER AUDIT SPECIFICATION (Transact-SQL) DROP SERVER AUDIT SPECIFICATION (Transact-SQL)
CREATE DATABASE AUDIT SPECIFICATION (Transact-SQL) CREATE DATABASE AUDIT SPECIFICATION (Transact-SQL)
DROP DATABASE AUDIT SPECIFICATION (Transact-SQL) DROP DATABASE AUDIT SPECIFICATION (Transact-SQL)
ALTER AUTHORIZATION (Transact-SQL) ALTER AUTHORIZATION (Transact-SQL)
sys.fn_get_audit_file (Transact-SQL) sys.fn_get_audit_file (Transact-SQL)
sys.server_audits (Transact-SQL) sys.server_audits (Transact-SQL)
sys.server_file_audits (Transact-SQL) sys.server_file_audits (Transact-SQL)
sys.server_audit_specifications (Transact-SQL) sys.server_audit_specifications (Transact-SQL)
sys.server_audit_specification_details (Transact-SQL) sys.server_audit_specification_details (Transact-SQL)
sys.database_audit_specifications (Transact-SQL) sys.database_audit_specifications (Transact-SQL)
sys.database_audit_specification_details (Transact-SQL) sys.database_audit_specification_details (Transact-SQL)
sys.dm_server_audit_status (Transact-SQL) sys.dm_server_audit_status (Transact-SQL)
sys.dm_audit_actions (Transact-SQL) sys.dm_audit_actions (Transact-SQL)
创建服务器审核和服务器审核规范Create a Server Audit and Server Audit Specification