触发器创建及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 is AFTER.
  • 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 for DELETE and UPDATE 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 simple SET that accumulates into a user variable the values inserted into the amount column. The statement refers to the column as NEW.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

时间: 2024-08-07 16:59:52

触发器创建及Navicat中使用的相关文章

Oracle 触发器在日志管理开发中的应用

摘要: 本文讨论了利用数据库中的触发器对日志管理进行设计与实现的方法, 是对原来在客户端软件中编写日志管理方法的一种改进, 并给出了 Oracle9i 中的实例演示.关键词: Oracle; 触发器; 日志管理中图分类号: TP311文献标识码: A文章编号: 1009- 3044(2008)16- 21186- 02The Application of Oracle Trigger in the Developing of Log ManagementWU Heng- liang, ZHANG

触发器创建删除等操作

一.创建一个简单的触发器 触发器是一种特殊的存储过程,类似于事件函数,SQL Server™ 允许为 INSERT.UPDATE.DELETE 创建触发器,即当在表中插入.更新.删除记录时,触发一个或一系列 T-SQL语句. 触发器可以在查询分析器里创建,也可以在表名上点右键->“所有任务”->“管理触发器”来创建,不过都是要写 T-SQL 语句的,只是在查询分析器里要先确定当前操作的数据库. 创建触发器用 CREATE TRIGGER CREATE TRIGGER 触发器名称ON 表名FOR

SQL Server触发器创建、删除、修改、查看示例步骤

SQL Server触发器创建.删除.修改.查看示例步骤 一﹕ 触发器是一种特殊的存储过程﹐它不能被显式地调用﹐而是在往表中插入记录﹑更新记录或者删除记录时被自动地激活.所以触发器可以用来实现对表实施复杂的完整性约`束. 二﹕ SQL Server为每个触发器都创建了两个专用表﹕Inserted表和Deleted表.这两个表. 一﹕ 触发器是一种特殊的存储过程﹐它不能被显式地调用﹐而是在往表中插入记录﹑更新记录或者删除记录时被自动地激活.所以触发器可以用来实现对表实施复杂的完整性约`束.    

在Navicat中如何设置HTTP属性

连接到服务器的方法有很多,HTTP通道就是其中的一种.其使用范围通常是在MySQL.PostgreSQL.SQLite 和MariaDB这几种之内.与网络服务器使用相同的通讯协定(http://)和端口(端口80),这是当互联网服务供应商不允许直接连接,但允许创建HTTP连接时使用.下面来给大家介绍介绍在Navicat中如何设置HTTP属性? 原文:http://www.formysql.com/jiqiao/shezhi-http.html 上传通道脚本 若要使用此连接方法,首先需要做的是上传

算法实验-二叉树的创建和前序-中序-后序-层次 遍历

对于二叉树的创建我是利用先序遍历的序列进行创建 能够对于树节点的内容我定义为char型变量 '0'为空,即此处的节点不存在 头文件 Tree.h //链式二叉树的头文件 #pragma once #include<iostream> #include<queue> using namespace std; class BinaryTreeNode { public: char data; BinaryTreeNode *leftChild,*rightChild; BinaryTr

dbus 创建Client过程中几个有用的函数

/**  * g_type_init:  *  * This function used to initialise the type system.  Since GLib 2.36,  * the type system is initialised automatically and this function does  * nothing.  *  * Deprecated: 2.36: the type system is now initialised automatically

使用eclipse创建在myeclipse中运行的web工程

今天在跟随慕课网学习java时,遇到课程中老师使用Myeclipse,我用的是eclipse,那么就使用eclipse创建在Myeclipse项目 参考: 使用eclipse创建在myeclipse中运行的web工程 http://jingyan.baidu.com/article/22fe7ced229c193003617f47.html 创建完了之后报错:HttpServlet was not found on the Java 解决: http://jingyan.baidu.com/ar

Navicat中MySQL server has gone away错误怎么办【转载】

转载链接:http://www.111cn.net/database/mysql/64073.htm mysql数据库出现MySQL server has gone away错误一般是sql语句太大导致了,下面们在使用Navicat中操作数据库时提示MySQL server has gone away问题解决办法. 备份数据时,生成的sql文件比较大,当然,这个sql是包含了比较多的冗余数据.用Navicat直接导入的话,报错MySQL server has gone away.如下图所示: 解

能否向编译后得到的类中增加实例变量?能否向运行时创建的类中添加实例变量?为什么

不能向编译后得到的类中增加实例变量!能向运行时创建的类中添加实例变量! 因为编译后的类已经注册在runtime中,类结构体中的objc_ivar_list 实例变量的链表和instance_size实例变量的内存大小已经确定,同时runtime 会调用class_setIvarLayout 或 class_setWeakIvarLayout来处理strong weak引用,所以不能向存在的类中添加实例变量. 运行时创建的类是可以添加实例变量,调用 class_addIvar 函数,但是得在调用