参考

http://www.mysqltutorial.org/mysql-triggers.aspx

mysql:triggers

被预先编写并存储在表中的程序, 该程序被特定的 events触发, 比如 对表的 DML 操作
By definition, a trigger or database trigger is a stored program executed automatically to respond to a specific event e.g., insert, update or delete occurred in a table.

被用于: 保护数据的完整性和一致性,
以及 自动 logging 和 审计 等

A SQL trigger is a set of SQL statements stored in the database catalog. A SQL trigger is executed or fired whenever an event associated with a table occurs e.g., insert, update or delete.

trigger vs stored procedure

A SQL trigger is a special type of stored procedure. It is special because it is not called directly like a stored procedure. The main difference between a trigger and a stored procedure is that a trigger is called automatically when a data modification event is made against a table whereas a stored procedure must be called explicitly.

advantages of Using triggers

  1. 提供了一个检查 数据完整性和一致性的方式

  2. 可以在数据库内捕捉 业务逻辑的错误

  3. 支持 run scheduled task

4, 支持对 数据变更的审查

disadvantages of Using triggers

  1. triggers仅能提供一种对数据审查的扩展, 而不能替代所有的审查工作

  2. triggers 执行对 clients不可见

  3. triggers 加大了mysql server 的负担

triggers 实现:

  1. 定义和存储 triggers
    You must use a unique name for each trigger associated with a table

The tablename.TRG file maps the trigger to the corresponding table.
the triggername.TRN file contains the trigger definition.

  1. the limitations of triggers

MySQL triggers cannot:

  • Use SHOW, LOAD DATA, LOAD TABLE, BACKUP DATABASE, RESTORE, FLUSH and RETURNstatements.
  • Use statements that commit or rollback implicitly or explicitly such as COMMIT , ROLLBACK , START TRANSACTION , LOCK/UNLOCK TABLES , ALTER , CREATE , DROP , RENAME.
  • Use prepared statements such as PREPAREand EXECUTE.
  • Use dynamic SQL statements.

create triggers

定义 tables 用来存放 triggers 获取的数据;

定义 tiggers, associated with a table;

scheduled event

类似于 定时器

mysql:triggers相关推荐

  1. mysql数据库有触发器吗_MySQL数据库之MySQL 触发器实现

    本文主要向大家介绍了MySQL数据库之MySQL 触发器实现 ,通过具体的内容向大家展现,希望对大家学习MySQL数据库有所帮助. Summary: in this tutorial, you wil ...

  2. mysql 触发器计算总价,mysql’插入’触发器根据其他字段计算字段

    我正在尝试创建一个触发器,它将根据用户输入的lat / lng列更新GEOMETRY列.我的触发器看起来像这样 – CREATE TRIGGER `tbl.foo` AFTER INSERT ON ` ...

  3. mysql触发器的简单入门(二)

    2019独角兽企业重金招聘Python工程师标准>>> 第一篇链接 https://my.oschina.net/aijiaoer0624/blog/1529475 先贴上代码: C ...

  4. beginning php and mysql_Beginning PHP and MySQL: From Novice to Professional, 5th Edition

    Beginning PHP and MySQL: From Novice to Professional By 作者: Frank M. Kromann ISBN-10 书号: 1430260432 ...

  5. mysql 触发器 bug_MySQL触发器不起作用

    我创建了以下触发器,但在插入数据后未执行 DELIMITER // CREATE TRIGGER sale_after_insert AFTER INSERT ON ano_sale_join FOR ...

  6. ERROR 1442 (HY000):because it is already used by statement which invoked this stored function/tr

    看到mysql的触发器,随手写了一个: mysql> create trigger t_ai_test -> after insert on test -> for each row ...

  7. mysql 表中触发器 TRIGGERS

    1.在 Mysql 表中允许有六个触发器,如下: (1)新增时: BEFORE INSERT AFTER INSERT (2)更新时: BEFORE UPDATE AFTER UPDATE (3)删除 ...

  8. mysql存储过程导出_Mysql导出存储过程

    在部署某学院的网站时,发现一个错误: FUNCTION config_get does not exist. 找到代码一看,是conn.prepareCall("{call config_g ...

  9. mysql多字段数据统计_超详细的mysql元数据sql统计--information_schema

    概述 information_schema 数据库跟 performance_schema 一样,都是 MySQL 自带的信息数据库.其中 performance_schema 用于性能分析,而 in ...

最新文章

  1. 一杯茶的功夫,掌握Git常用命令(转载)
  2. mysql case设固定值_MySQL CASE语句将自定义值放置为NULL
  3. GZFramwork数据库层《四》单据主从表增删改查
  4. Impala性能优化
  5. ui kit html,开始使用
  6. Log4Net 最简配置
  7. wifi上行下行速度测试_增大AP天线增益,可以同时改善上下行 —— WIFI基础知识(3)...
  8. 【目标检测_CentripetalNet】CentripetalNet: Pursuing High-quality Keypoint Pairs for Object Detection_2020
  9. 2021 年软件工程现状:Python 或将成为第一大编程语言,中国开源涨势最猛
  10. 前端、后台和连接前端后台的网络数据传输
  11. [20150304]唯一索引与阻塞.txt
  12. 【动手学深度学习】代码(持续更新)
  13. POJ 3134 - Power Calculus (IDDFS)
  14. json字符串转json对象
  15. ssh框架的基本运用
  16. 屏蔽全部统计代码(51.la cnzz 百度统计 谷歌分析师adsense、屏蔽淘宝客广告代码)的方法...
  17. 【Python实战】有趣的代码百里挑一:这款“水波特效”脚本送给你,绝版哦~(建议保留)
  18. Kali BeEF MSF的使用
  19. 微信公众号数据2019_2019年4月房地产微信公众号排行榜:郑州楼市第一
  20. ON_NOTIFY用法

热门文章

  1. 读书笔记:redis开发与运维 基础篇
  2. 社会知觉:我们如何理解他人
  3. C51学习笔记 9.蜂鸣器
  4. 最全的测绘、地信数据格式介绍
  5. 紫薯第10章数学 kaungbin专题14数论基础
  6. [下载]免费网页密码破解软件─WebCracker 4.0 汉化注册版下载
  7. sql多维度组合排序
  8. Redis保存购物车信息
  9. IDEA好用的插件推荐
  10. 2020h黑苹果 y7000p_联想拯救者 篇一:联想拯救者Y7000P 2020H测评之联想电脑管家(上)...