ALTER DATABASE AUDIT SPECIFICATION (Transact-SQL)

Alters a database audit specification object using the SQL Server Audit feature. For more information, see Understanding SQL Server Audit.

Topic link iconTransact-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 [ (column [ ,...n ] ) ] 
     BY principal [ ,...n ] 
}

<action_specification>::=
{
        action [ (column [ ,...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 Table1(Column1)
         BY dbo)
    WITH STATE = ON;
GO

For a full example about how to create an audit, see Understanding SQL Server Audit.

See Also

Reference

Concepts