触发器创建及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 ...
随机推荐
- 【PHP设计模式 09_ZhuangShiQi.php】装饰器模式 (decorator)
<?php /** * [装饰器模式 (decorator)] * 有时候发布一篇文章需要经过很多人手,层层处理 */ header("Content-type: text/html; ...
- recycleview + checkbox 实现单选
使用map集合记录checkbox的选中状态 private HashMap<Integer,Boolean> positionMap; positionMap = new HashMap ...
- java double类型保留两位小数4种方法【转】
4种方法,都是四舍五入,例: import java.math.BigDecimal; import java.text.DecimalFormat; import java.text.NumberF ...
- php之属性重载和方法重载
<?php /** * * @authors Your Name (you@example.org) * @date 2016-06-13 20:40:19 * @version $Id$ */ ...
- Help Me with the Game 分类: POJ 2015-06-29 16:34 17人阅读 评论(0) 收藏
Help Me with the Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3706 Accepted: ...
- Java学习之路(六)
1:包及和访问权限 将类放置到一个包当中,需要使用package “包名” 编译时需要使用 -d 参数 该参数的作用是依照包名生成相应的文件夹 一个类的全民应该是 “包名” + “.” + “类名 ...
- Python学习笔记-Day2-Python基础之元组操作
元组的常用操作包括但不限于以下操作: 元组的索引,计数等 这里将对列表的内置操作方法进行总结归纳,重点是以示例的方式进行展示. 使用type获取创建对象的类 type(tuple) 使用dir获取类的 ...
- Winform容器标签 打印标签 对话框控件
一.容器标签 布局: Anchor:锁定位置,指定与窗口容器的边缘位置,会随着窗口大小的改变而改变: Dock:填充窗口的位置.一般与容器标签同时使用. 1.Panel:对控件进行分组.可以独立布局, ...
- dubbo源码之三——dubbo重构
dubbo版本:2.5.4 转自:http://javatar.iteye.com/blog/1041832
- c++学习笔记2--constexpr,类型别名,auto
constexpr:修饰常量表达式,约定修饰对象不仅为常量,而且在编译阶段就能得到值. 与const不同的是,constexpr约束的是当事人,就是说,constexpr int *a=1;这样的语句 ...