MySQL Tutorial's trigger writing * *
Trigger_name: The name of the trigger, my usual naming convention t_name_tablename_ (B|a) (i|u|d), T: Trigger ID, Name: English name, TableName: Table name, B (before): identity is before triggering event, a ( After): Identifies the trigger event, I (insert): Identifies the Insert event, U (UPDATE): Identifies the update event, D (delete): Identifies the delete event;
Trigger_time: Trigger time (before or after)
Trigger_event: Event name (insert or update or delete)
Tbl_name: Table name (must be a permanent table)
TRIGGER_STMT: Execute statements (which can be compound names), use alias old and new to refer to columns in the table associated with the trigger.
delimiter//
Create trigger insert_mysql_test before insert on test
For each row
Begin
INSERT INTO tem set ID = new ID, name = new name;
The id,name behind the/*new is the field name of the test table * *
End
//
/*mysql's Trigger Writing * *
Create a MySQL Trigger
Create Trigger Trigger_name trigger_time trigger_event on Tbl_name
For each row
Begin
Trigger_stmt
End
Remove the Hair picker
Grammar:
Drop trigger [schema_name.] Trigger_name;
Note: The above operation requires super privilege
Drop trigger if exists ' trig_t_chatuserinfo_ad '