ALTER DATABASE AUDIT SPECIFICATION (Transact-SQL)

Alters a database audit specification object using the SQL Server Audit feature. For more information, see SQL Server Audit (Database Engine).

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 ] 
}

Arguments

  • audit_specification_name
    The name of the audit specification.

  • audit_name
    The name of the audit to which this specification is applied.

  • audit_action_specification
    Name of one or more database-level auditable actions. For a list of audit action groups, see SQL Server Audit Action Groups and Actions.

  • audit_action_group_name
    Name of one or more groups of database-level auditable actions. For a list of audit action groups, see SQL Server Audit Action Groups and Actions.

  • class
    Class name (if applicable) on the securable.

  • securable
    Table, view, or other securable object in the database on which to apply the audit action or audit action group. For more information, see Securables.

  • column
    Column name (if applicable) on the securable.

  • principal
    Name of SQL Server principal on which to apply the audit action or audit action group. For more information, see Principals (Database Engine).

  • WITH ( STATE = { ON | OFF } )
    Enables or disables the audit from collecting records for this audit specification. 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. You must set the state of an audit specification to the OFF option in order to make changes to a 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. For more information, see tempdb Database.

Permissions

Users with the ALTER ANY DATABASE AUDIT permission can alter database audit specifications and bind them to any audit.

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

The following example alters a database audit specification called HIPPA_Audit_DB_Specification that audits the SELECT statements by the dbo user, for a SQL Server audit called HIPPA_Audit.

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

For a full example about how to create an audit, see SQL Server Audit (Database Engine).

See Also

Reference

CREATE SERVER AUDIT (Transact-SQL)

ALTER SERVER AUDIT (Transact-SQL)

DROP SERVER AUDIT (Transact-SQL)

CREATE SERVER AUDIT SPECIFICATION (Transact-SQL)

ALTER SERVER AUDIT SPECIFICATION (Transact-SQL)

DROP SERVER AUDIT SPECIFICATION (Transact-SQL)

CREATE DATABASE AUDIT SPECIFICATION (Transact-SQL)

DROP DATABASE AUDIT SPECIFICATION (Transact-SQL)

ALTER AUTHORIZATION (Transact-SQL)

sys.fn_get_audit_file (Transact-SQL)

sys.server_audits (Transact-SQL)

sys.server_file_audits (Transact-SQL)

sys.server_audit_specifications (Transact-SQL)

sys.server_audit_specification_details (Transact-SQL)

sys.database_audit_specifications (Transact-SQL)

sys.database_audit_specification_details (Transact-SQL)

sys.dm_server_audit_status (Transact-SQL)

sys.dm_audit_actions (Transact-SQL)

Concepts

Create a Server Audit and Server Audit Specification

Change History

Updated content

Corrected the Permissions section.