触发器创建及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
BEFORE
indicates 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
INSERT
indicates the trigger event; that is, the type of operation that activates the trigger. In the example,INSERT
operations cause trigger activation. You can also create triggers forDELETE
andUPDATE
operations.The statement following
FOR EACH ROW
defines 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 simpleSET
that accumulates into a user variable the values inserted into theamount
column. The statement refers to the column asNEW.amount
which means “the value of theamount
column 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 ...
随机推荐
- iOS开发- 蓝牙后台接收数据(BLE4.0)
最近在做一个蓝牙相关的项目, 需要在应用进入后台, 或者手机属于锁屏状态的情况下, 仍然保持蓝牙连接, 并且能正常接收数据. 本来以后会很麻烦, 但是学习了下..发现就2步而已.简单的不能再简单了. ...
- HTTP Live Streaming直播(iOS直播)技术分析与实现
本文转载自:http://www.cnblogs.com/haibindev/archive/2013/01/30/2880764.html 不经意间发现,大半年没写博客了,自觉汗颜.实则2012后半 ...
- 霸气的jQ插件
http://codepen.io/ canvas的各种实例 1.The Responsive jQuery Content Slider http://bxslider.com/ 2.ThemePu ...
- c# Beginlnvoke 委托
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- windows下TCP服务器和客户端的实现
服务器 1.初始化 WSAStartup(..) 2.创建Socket s = Socket ( .. ) 3.绑定端口 ret = bind ( ... ) 4.监听 ret = ...
- vilte/vowifi
vendor/mediatek/proprietary/packages/services/Ims/src/com/mediatek/ims/ImsService.java ¦ ¦ ¦ ¦ ¦ ¦ v ...
- C# .ToString() 格式化
c# ToString() 格式化字符串 格式化数值:有时,我们可能需要将数值以一定的格式来呈现,就需要对数值进行格式化.我们使用格式字符串指定格式.格式字符串采用以下形式:Axx,其中 A 为格式 ...
- SPRING官方网下载地址
SPRING官方网站改版后,建议都是通过 Maven和Gradle下载,对不使用Maven和Gradle开发项目的,下载就非常麻烦,下给出Spring Framework jar官方直接下载路径: h ...
- sql 百万级数据库优化方案
转自http://blog.sina.com.cn/s/blog_724cd89d0100ppcz.html 1.对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉 ...
- ADO,NET 实体类 和 数据访问类
啥也不说,看代码. --SQl中 --建立ren的数据库,插入一条信息 create database ren go use ren go create table xinxi ( code ) pr ...