O'Reilly logo

SQL in a Nutshell by Kevin Kline

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

ALTER TRIGGER

Synopsis

The ALTER TRIGGER statement modifies a preexisting trigger definition without altering permissions or dependencies.

Vendor

Command

SQL Server

Supported, with variations

MySQL

Not supported

Oracle

Supported, with variations

PostgreSQL

Not supported

SQL99 Syntax and Description

Currently, there is no SQL99 standard for this command.

Microsoft SQL Server Syntax and Variations

ALTER TRIGGER trigger_name
ON {table_name | view_name}
[WITH ENCRYPTION]
{FOR | AFTER | INSTEAD OF} {[DELETE] [,] [INSERT] [,] [UPDATE]}
[WITH APPEND]
[NOT FOR REPLICATION]
AS
  T-SQL_block
| [FOR { [INSERT] [,] [UPDATE] }
[NOT FOR REPLICATION]
AS
 
  { IF UPDATE(column) [{AND | OR} UPDATE(column)] [...n]
    | 
    IF (COLUMNS_UPDATED(  ) {bitwise_operator} updated_bitmask) 
    { comparison_operator} column_bitmask [...n] }
    T-SQL_block ] } ]

Microsoft SQL Server allows the specification of FOR | AFTER | INSTEAD OF { [DELETE] [,] [UPDATE] [,][INSERT] } | { [INSERT] [,] [UPDATE] } to describe which data-modification statement trigger is affected by the command. At least one of these is required, but any combination is allowed with extra options separated by commas. The options FOR and AFTER are essentially the same, causing the trigger code to fire after the data-manipulation operation has completed. Alternately, the INSTEAD OF key phrase tells SQL Server to substitute the data-manipulation operation completely with the code of the trigger.

The WITH APPEND key phrase tells SQL Server to append an ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required