触发器创建及Navicat中使用
mysql中的触发器(trigger)使用
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 TRIGGER statement creates a trigger named ins_sum that is associated with the account table. 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 isAFTER.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 forDELETEandUPDATEoperations.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 simpleSETthat accumulates into a user variable the values inserted into theamountcolumn. The statement refers to the column asNEW.amountwhich means “the value of theamountcolumn 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中使用的更多相关文章
- Oracle 触发器在日志管理开发中的应用
摘要: 本文讨论了利用数据库中的触发器对日志管理进行设计与实现的方法, 是对原来在客户端软件中编写日志管理方法的一种改进, 并给出了 Oracle9i 中的实例演示.关键词: Oracle; 触发器; ...
- 【Mysql】mysql使用触发器创建hash索引
概述 若设计的数据表中,包含较长的字段,比如URL(通常都会比较长),查询时需要根据该字段进行过滤: select * from table_xxx where url = 'xxxxxxx'; 为了 ...
- java连接Oracle数据库实现增删改查并在Navicat中显示
创建TEST表 eclipse中的java项目 代码 数据库方法类 DBUtil: package util; import java.sql.Connection; import java.sql. ...
- 在Navicat中如何新建数据库和表并做查询
上一篇文章,小编给大家分享了在Navicat中如何远程连接数据库,没有来得及上车的小伙伴可以戳这篇文章:在Ubuntu14.04中配置mysql远程连接教程.今天小编给大家分享一下如何在Navicat ...
- Eclipse在已创建的project中导入其他文件
Eclipse在已创建的project中导入其他文件 前两天被同事问到,如何通过不拷贝源文件的方式,在之前已经创建好的project中直接导入其他目录下的文件, 整理了一下,将目前所知道的eclips ...
- 使用eclipse创建在myeclipse中运行的web工程
今天在跟随慕课网学习java时,遇到课程中老师使用Myeclipse,我用的是eclipse,那么就使用eclipse创建在Myeclipse项目 参考: 如何在Eclipse配置Tomcat服务器 ...
- 在Navicat 中给Mysql中的某字段添加前缀00
第一次分享心得,希望大家多多关注. 我遇到的情况是这样的,在Navicat中某表的varchar字段内容长度不够5的在内容前面添加‘0’:如字段内容是 101 我就要改成00101: 其中有2个难点: ...
- 创建类似于Oracle中decode的函数
-- 创建类似于Oracle中decode的函数create or replace function decode(variadic p_decode_list text[])returns text ...
- 1.django项目的创建(在CMD中)
django项目的创建(在CMD中) 1.切换到你想要存储项目的位置,我这里保存在桌面上 cd Desktop 2.创建一个django项目,项目名叫guest django-admin startp ...
随机推荐
- 用excel2010 制作复合图表
用excel2010制作双轴柱线复合图表就是要用excel2010做一个这样的图表:
- CRB and His Birthday(背包)
CRB and His Birthday Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others ...
- 这题实在不知道起啥名好了 分类: sdutOJ 2015-06-22 17:17 19人阅读 评论(0) 收藏
这题实在不知道起啥名好了 Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 懒得想背景故事了,开门见山. 有一个长度为n的整数数列A ...
- OracleHelper
/// <summary> /// OracleServer数据库访问的通用工具类 /// </summary> public abstract class OracleHel ...
- /etc/ld.so.conf 介绍
/etc/ld.so.conf 这个文件记录了编译时使用的动态链接库的路径,告诉链接器去哪个路径下寻找链接时需要用到的库,如果找不到,就会提示链接错误. 如果我们安装了第三方的库,而没有将它放在链接器 ...
- Codeforces Round #370 (Div. 2) B
Description Memory is performing a walk on the two-dimensional plane, starting at the origin. He is ...
- hibernate.properties
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect #hibernate.dialect=org.hibernate.dialect.Oracl ...
- nuget使用
我如何获得的NuGet安装/更新的packages.config所有的软件包? nuget我有一个在它的多个项目的解决方案.大多数第三方引用的缺失,但也有packages.config文件为每个项目. ...
- 课务IOS概述_1
1.网络 2.多线程 3.各种图形 4.动画 5.面向对象的数据库 Preconditions: 1.CS106 A和B 或CS106X 2.CS107或CS108更好 3.CS110就更好了 熟 ...
- VC++ 线程同步 总结
注:所谓同步,并不是多个线程一起同时执行,而是他们协同步调,按预定的先后次序执行. 与线程相关的基本函数包括:CreateThread:创建线程CloseHandle:关闭线程句柄.注意,这只会使指定 ...