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