Concept

Database trigger

Summary
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. Below follows a series of descriptions of how some popular DBMS support triggers. 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. 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. From Oracle 8i, database events - logons, logoffs, startups - can fire Oracle triggers. 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. 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.
About this result
This page is automatically generated and may contain information that is not correct, complete, up-to-date, or relevant to your search query. The same applies to every other page on this website. Please make sure to verify the information with EPFL's official sources.