SQL Triggers

Triggers execute specific SQL commands when specific database events transpire on specific tables. The general syntax for creating a trigger is as follows:

create [temp|temporary] trigger name
[before|after] [insert|delete|update|update of columns] on table

action

A trigger is defined by a name, an action, and a table. The action, or trigger body, consists of a series of SQL commands. Triggers are said to fire when such events take place. Furthermore, triggers can be made to fire before or after the event using the before or after keyword, respectively. Events include delete, insert, and update commands issued on the specified table. Triggers can be used to create your own integrity constraints, log changes, update other tables, and many other things. They are limited only by what you can write in SQL.

If you choose to include [for each row], the trigger will be a row-level trigger, i.e., it will be executed for each affected row. (SQL Server, SQLite etc.)