Create a mysql trigger

Source: Internet
Author: User
Tags mysql tutorial

This tutorial describes how to create a trigger instance in mysql. mysql creates a trigger that is supported at mysql 5.0.2, and a trigger is a database object related to a table that is triggered when the defined conditions are met, and execute the defined trigger set. This feature of the trigger can assist in the integrity of the application database.

This tutorial introduces how to create a trigger instance in the mysql tutorial.Create a triggerThe trigger is supported at mysql5.0.2 and is a database tutorial object related to tables. It is triggered when the definition conditions are met and the defined trigger set is executed, this feature of triggers can assist in the integrity of the application database.

I. HowCreate a mysql trigger

Create frigger griggername triggerevent on tablename from each row tariglist;

Note: triggers can only be created on permanent tables, but not on temporary tables or views.

The mysql trigger time can be before after. The former means to specify the trigger before the constraints are checked, while the latter triggers after the constraints.

Next let's look at an instance.

Delimiter $

Create trigger issfile

After insert on film for each row begin

Insert into filetxt (fileid, title, desc) values (n. id, n. title, n. des );

End;

$

Delimiter;

When a film record is inserted, a relative record is inserted into filetext.

Mysql> insert into film values

-> (10, www. bKjia. c0m );

Query OK, 1 rows affected (0.05 sec );

Mysql> select * from filmtext where filmid = 10G

Fileid: 10

.....

1row in set (0.00 sec );

Okay, this tutorial introducesCreate a mysql triggerAnd insert data and a simple introduction.

Original tutorial on this site to indicate the source www. bKjia. c0m/database/database.html

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.