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

适用于:Applies to: 是SQL ServerSQL Server(所有支持的版本)yesSQL ServerSQL Server (all supported versions) 是Azure SQL 托管实例Azure SQL Managed InstanceYesAzure SQL 托管实例Azure SQL Managed Instance适用于:Applies to: 是SQL ServerSQL Server(所有支持的版本)yesSQL ServerSQL Server (all supported versions) 是Azure SQL 托管实例Azure SQL Managed InstanceYesAzure SQL 托管实例Azure SQL Managed Instance

使用 SQL ServerSQL Server 审核功能更改服务器审核规范对象。Alters a server 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 SERVER AUDIT SPECIFICATION audit_specification_name  
{  
    [ FOR SERVER AUDIT audit_name ]  
    [ { { ADD | DROP } ( audit_action_group_name )  
      } [, ...n] ]  
    [ WITH ( STATE = { ON | OFF } ) ]  
}  
[ ; ]  

备注

若要查看 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_group_name**audit_action_group_name
服务器级别可审核操作组的名称。Name of a group of server-level auditable actions. 要获取审核操作组列表,请参阅 SQL Server 审核操作组和操作For a list of Audit Action Groups, see SQL Server Audit Action Groups and Actions.

WITH ( STATE = { ON | OFF } )************WITH ( STATE = { ON | OFF } )
允许或禁止审核收集此审核规范的记录。Enables or disables the audit from collecting records for this audit specification.

备注Remarks

必须将审核规范的状态设置为 OFF 选项,以便更改审核规范。You must set the state of an audit specification to the OFF option to make changes to an audit specification. 使用 STATE=OFF 以外的任何选项启用审核规范时,如果执行 ALTER SERVER AUDIT SPECIFICATION,您将接收到一条错误消息。If ALTER SERVER AUDIT SPECIFICATION is executed when an audit specification is enabled with any options other than STATE=OFF, you will receive an error message.

权限Permissions

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

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

示例Examples

下面的示例创建一个称为 HIPAA_Audit_Specification 的服务器审核规范。The following example creates a server audit specification called HIPAA_Audit_Specification. 它删除了失败登录的审核操作组,为称作 HIPAA_AuditSQL ServerSQL Server Audit 的数据库对象访问添加了一个审核操作组。It drops the audit action group for failed logins, and adds an audit action group for Database Object Access for a SQL ServerSQL Server audit called HIPAA_Audit.

ALTER SERVER AUDIT SPECIFICATION HIPAA_Audit_Specification  
FOR SERVER AUDIT HIPAA_Audit  
    DROP (FAILED_LOGIN_GROUP),  
    ADD (DATABASE_OBJECT_ACCESS_GROUP)  
    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)
DROP SERVER AUDIT SPECIFICATION (Transact-SQL) DROP SERVER AUDIT SPECIFICATION (Transact-SQL)
CREATE DATABASE AUDIT SPECIFICATION (Transact-SQL) CREATE DATABASE AUDIT SPECIFICATION (Transact-SQL)
ALTER DATABASE AUDIT SPECIFICATION (Transact-SQL) ALTER 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