MySQL trigger to update and insert operations

   Trigger (trigger): monitoring certain conditions, and trigger some kind of action, which is available to programmers and data analysts a way to ensure data integrity, which is associated with a table event special storage process, it implementation is not called by the program, not manually start, but is triggered by an event, such as when a table operation (insert, delete, update) will be activated to perform it.
        Triggers are often used to enhance data integrity constraints and business rules and so on. Trigger creation syntax four elements:
        1. monitoring site (the Table)
        2. monitor events (insert / update / delete) 
        3. Trigger time (the After / the before) 
        4. triggering event (insert / update / delete)
        triggers basic syntax is as follows below:


        Where: trigger_time trigger event triggers, can be before (in front of the trigger check constraint) or after (fire after check constraints); trigger_event triggering event triggers, including insert, update and delete, should pay attention to the same same table trigger the same trigger event time, only the definition of a trigger; can be used to reference the old and the new record content changes trigger.
        Triggers SQL syntax:
 
the Create the Trigger triggerName  
the After / the before INSERT / Update / the Delete ON table name  
for each row # This sentence is fixed in mysql  
the begin  
    SQL statements;  
End;  

Guess you like

Origin www.cnblogs.com/remember-forget/p/11446219.html