CREATE SERVER AUDIT SPECIFICATION (Transact-SQL)CREATE 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 Audit 功能创建服务器审核规范对象。Creates 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

CREATE SERVER AUDIT SPECIFICATION audit_specification_name  
FOR SERVER AUDIT audit_name  
{  
    { ADD ( { 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
服务器审核规范的名称。Name of the server audit specification.

audit_name**audit_name
应用此规范的审核的名称。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

审核必须已存在,才能为它创建服务器审核规范。An audit must exist before creating a server audit specification for it. 服务器审核规范在创建之后处于禁用状态。When a server audit specification is created, it is in a disabled state.

权限Permissions

具有 ALTER ANY SERVER AUDIT 权限的用户可以创建服务器审核规范并将其绑定到任何审核。Users with the ALTER ANY SERVER AUDIT permission can create 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_SpecificationSQL ServerSQL Server Audit 创建称为 HIPAA_Audit 的服务器审核规范,该规范可对失败的登录进行审核。The following example creates a server audit specification called HIPAA_Audit_Specification that audits failed logins, for a SQL ServerSQL Server Audit called HIPAA_Audit.

CREATE SERVER AUDIT SPECIFICATION HIPAA_Audit_Specification  
FOR SERVER AUDIT HIPAA_Audit  
    ADD (FAILED_LOGIN_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)
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)
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