触发器创建及Navicat中使用
2016-10-31 19:34
330 查看
mysql中的触发器(trigger)使用
Trigger:
示例:
解析:<原谅我这懒惰的搬运工>
The
The keyword
The keyword
The statement following
具体参见:http://dev.mysql.com/doc/refman/5.7/en/trigger-syntax.html
Navicat中使用
1.选中要添加触发器的表;
2.打开其设计表;
3.打开触发器,在指定栏中设置触发器;
具体参见:http://blog.csdn.net/cqnuztq/article/details/9735245
Trigger:
示例:
mysql> CREATE TABLE account (acct_num INT, amount DECIMAL(10,2)); Query OK, 0 rows affected (0.03 sec) mysql> CREATE TRIGGER ins_sum BEFORE INSERT ON account -> FOR EACH ROW SET @sum = @sum + NEW.amount; Query OK, 0 rows affected (0.06 sec)
解析:<原谅我这懒惰的搬运工>
The
CREATE TRIGGERstatement creates a trigger named
ins_sumthat is associated with the
accounttable. It also includes clauses that specify the trigger action time, the triggering event, and what to do when the trigger activates:
The keyword
BEFOREindicates the trigger action time. In this case, the trigger activates before each row inserted into the table. The other permitted keyword here is
AFTER.
The keyword
INSERTindicates the trigger event; that is, the type of operation that activates the trigger. In the example,
INSERToperations cause trigger activation. You can also create triggers for
DELETEand
UPDATEoperations.
The statement following
FOR EACH ROWdefines the trigger body; that is, the statement to execute each time the trigger activates, which occurs once for each row affected by the triggering event. In the example, the trigger body is a simple
SETthat accumulates into a user variable the values inserted into the
amountcolumn. The statement refers to the column as
NEW.amountwhich means “the value of the
amountcolumn to be inserted into the new row.”
具体参见:http://dev.mysql.com/doc/refman/5.7/en/trigger-syntax.html
Navicat中使用
1.选中要添加触发器的表;
2.打开其设计表;
3.打开触发器,在指定栏中设置触发器;
具体参见:http://blog.csdn.net/cqnuztq/article/details/9735245
相关文章推荐
- 利用navicat创建存储过程、触发器和使用游标的简单实例
- navicat创建存储过程、触发器和使用游标
- 利用navicat创建存储过程、触发器和使用游标的简单实例
- navicat中创建存储过程、触发器和使用游标的简单实例(图文)
- 利用navicat创建存储过程、触发器和使用游标的简单实例
- 利用navicat创建存储过程、触发器和使用游标的简单实例
- 利用navicat创建存储过程、触发器和使用游标的简单实例
- 利用navicat创建存储过程、触发器和使用游标的简单实例
- 利用navicat创建存储过程、触发器和使用游标的简单实例
- 利用navicat创建存储过程、触发器和使用游标的简单实例
- 利用navicat创建存储过程、触发器和使用游标的简单实例
- 利用navicat创建存储过程、触发器和使用游标的简单实例
- SQLServer2005里怎样对使用with encryption选项创建的解密存储过程、解密函数、触发器、视图
- 在创建触发器时出现不能在 'inserted' 表和 'deleted' 表中使用 text、ntext 或 image 列
- Setup Factory 7.0使用总结七:创建数据表、序列、触发器
- oracle - 使用触发器创建自增列
- 创建能够处理多行的触发器时可使用的联接方式
- 触发器的创建和使用(sql2005)
- Navicat for MySQL使用手记(上)--创建数据库和表
- 使用Navicat For MySql 将mysql中的数据导出,包括数据库表创建脚本和数据