A database trigger is procedural code that is automatically executed in response to certain events on a particular table or view in a database. The trigger is mostly used for maintaining the integrity of the information on the database. For example, when a new record (representing a new worker) is added to the employees table, new records should also be created in the tables of the taxes, vacations and salaries. Triggers can also be used to log historical data, for example to keep track of employees' previous salaries. Triggers in DBMS Below follows a series of descriptions of how some popular DBMS support triggers. Oracle In addition to triggers that fire (and execute PL/SQL code) when data is modified, Oracle 10g supports triggers that fire when schema-level objects (that is, tables) are modified and when user logon or logoff events occur. Schema-level triggers After Creation Before Alter After Alter Before Drop After Drop Before Insert The four main types of triggers are: Row-level trigger: This gets executed before or after any column value of a row changes Column-level trigger: This gets executed before or after the specified column changes For each row type: This trigger gets executed once for each row of the result set affected by an insert/update/delete For each statement type: This trigger gets executed only once for the entire result set, but also fires each time the statement is executed. System-level triggers From Oracle 8i, database events - logons, logoffs, startups - can fire Oracle triggers. Microsoft SQL Server A list of all available firing events in Microsoft SQL Server for DDL triggers is available on Microsoft Docs. Performing conditional actions in triggers (or testing data following modification) is done through accessing the temporary Inserted and Deleted tables. PostgreSQL Introduced support for triggers in 1997. The following functionality in SQL:2003 was previously not implemented in PostgreSQL: SQL allows triggers to fire on updates to specific columns; As of version 9.0 of PostgreSQL this feature is also implemented in PostgreSQL. The standard allows the execution of a number of SQL statements other than SELECT, INSERT, UPDATE, such as CREATE TABLE as the triggered action. This can be done through creating a stored procedure or function to call CREATE TABLE. Synopsis: CREATE TRIGGER name { BEFORE | AFTER } { event [ OR ... ] } ON TABLE [ FOR [ EACH ] { ROW | STATEMENT } ]