MySQL's trigger notation

Source: Internet
Author: User

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 '

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.