How to Write a trigger in the mysql tutorial */
Trigger_name: name of the trigger. My commonly used naming rules are t_name_tablename _ (B | a) (I | u | d), t: trigger ID, name: English name, tablename: Table name, B (before): before the event is triggered, a (after): after the event is triggered, I (insert): identifies the insert event, u (update): identifies the update event, d (delete): identifies a delete event;
Trigger_time: trigger time (before or after)
Trigger_event: event name (insert, update, or delete)
Tbl_name: Table Name (must be a permanent table)
Trigger_stmt: Execute the statement (which can be a compound language name). Use the old and new aliases to reference columns in the table related to the trigger program.
Delimiter //
Create trigger insert_mysql_test before insert on test
For each row
Begin
Insert into tem set id = new id, name = new name;
/* Id after new. name is the field name of the test table */
End
//
/* Mysql trigger Writing Method */
Create a mysql trigger
Create trigger trigger_name trigger_time trigger_event on tbl_name
For each row
Begin
Trigger_stmt
End;
Delete the producer
Syntax:
Drop trigger [schema_name.] trigger_name;
Note: The above operations require the super permission.
Drop trigger if exists 'trig _ t_chatuserinfo_ad'