A conceptual trigger is a special transaction that listens to addition, deletion, and modification operations and triggers addition, deletion, and modification operations. It is mainly used to process some complicated business logic to ensure the linkage of data. It includes four elements: 1. Monitoring location (table) 2. Monitoring event (insertupdatedelete) 3. triggering time (afterbefore) 4. Triggering Event (insertupdated
A conceptual trigger is a special transaction that listens to addition, deletion, and modification operations and triggers addition, deletion, and modification operations. It is mainly used to process some complicated business logic to ensure the linkage of data. It includes four elements: 1. monitoring location (table) 2. monitoring event (insert/update/delete) 3. trigger time (after/before) 4. trigger event (insert/update/d
Concept
A trigger is a special transaction that listens to addition, deletion, and modification operations and triggers addition, deletion, and modification operations. It is mainly used to process some complicated business logic to ensure the linkage of data. It includes four elements: 1. monitoring location (table) 2. monitoring event (insert/update/delete) 3. trigger time (after/before) 4. trigger event (insert/update/delete)
Syntax
Create trigger 'trigger name' 'trigger time (after | before) '': 'On 'TRIGGER location' for each row begin sql1; sql2; sql3; END $
For each row is used to identify the trigger type. because Mysql supports ROW-level triggers and does not support statement triggers, you can only use for each row. Because the trigger uses ';' to differentiate multiple event statements, you need to redefine the delimiters.
Instance
Modify the delimiter to $
Create a trigger
View triggers
Before performing the operation
Table t4 data is as follows:
Table t3 data is as follows:
After performing the corresponding operation