Mysql-trigger-Trigger

Source: Internet
Author: User

In SQL, a noun trigger refers to a program code that executes automatically in a database in response to certain events in a particular table. "(Wikipedia) is simpler to say, it is a piece of code that is automatically activated when a particular database event, such as insert or delete, occurs. Triggers can be conveniently used for logging, automatic "cascading" changes to individual tables to other linked tables, or automatic updating of table relationships. When a new integer value is added to the database domain, the code snippet that automatically updates the total number of runs is a trigger. The SQL command block that automatically records changes made to a particular database table is also a trigger instance.


Show triggers

Show triggers;


Delete Trigger

Drop TRIGGER Trigger Name


Grammar

CREATE TRIGGER < trigger name > <--
{before | After}
{INSERT | UPDATE | DELETE}
On < table name >
For each ROW
< trigger SQL statements >


Example

CREATE TRIGGER Trigger_test
After
INSERT
On a
For each ROW
INSERT INTO B set b_name= "Trigger_test_name"

Mysql-trigger-Trigger

Related Article

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.