A trigger is a special type of stored procedure. Triggers are mainly triggered by events (add, delete, change) and are automatically called and executed. Triggers are often used to enforce business rules. They are high-level constraints that are triggered by events and executed. Stored procedures can be called by the name of the stored procedure.
Trigger is a method provided by SQL server to programmers and data analysts to ensure data integrity. It is a special method related to table events. The execution of a stored procedure is not called by a program or started manually, but is triggered by events. For example, when a table is operated (insert, delete, update), its execution is activated. Triggers are often used to enforce data integrity constraints and business rules. Triggers can be found in the DBA_TRIGGERS and USER_TRIGGERS data dictionaries. A SQL3 trigger is a statement that can be automatically executed by the system to modify the database.
Trigger timing: Specify the triggering time of the trigger. If it is specified as BEFORE, it means that it is triggered before the DML operation is performed in order to prevent certain error operations from occurring or to implement certain business rules; if it is specified as AFTER, it means that it is triggered after the DML operation is performed in order to record the operation or do certain things. Deal with it afterwards.
Trigger event: causes the trigger to be triggered, that is, DML operation. It can be either a single trigger event or a combination of multiple trigger events (only OR logical combination can be used, and AND logical combination cannot be used).
The above is the detailed content of When does the trigger execute?. For more information, please follow other related articles on the PHP Chinese website!