zoukankan      html  css  js  c++  java
  • mysql触发器2

    更新

    mysql> create trigger t2
    -> after
    -> insert on ord
    -> for each row
    -> begin update goods set num=num-new.mch where gid = new.gid;
    -> end$
    Query OK, 0 rows affected (0.02 sec)

    mysql> 查看已有触发器trigger
    -> ^C
    mysql> show tigger;

    删除:

    mysql> create trigger t3 after delete on ord
    -> for each row begin update goods set num = num -old.mch where
    -> gid = old.gid;end $
    Query OK, 0 rows affected (0.02 sec)

    mysql> show triggers;
    -> $
    +---------+--------+-------+-------------------------------------------------------------------+--------+------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+----------------+----------------------+----------------------+--------------------+
    | Trigger | Event | Table | Statement | Timing | Created | sql_mode | Definer | character_set_client | collation_connection | Database Collation |
    +---------+--------+-------+-------------------------------------------------------------------+--------+------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+----------------+----------------------+----------------------+--------------------+
    | t2 | INSERT | ord | begin update goods set num=num-new.mch where gid = new.gid;
    end | AFTER | 2019-06-03 07:47:00.22 | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION | root@localhost | utf8 | utf8_general_ci | utf8_general_ci |
    | t3 | DELETE | ord | begin update goods set num = num -old.mch where
    gid = old.gid;end | AFTER | 2019-06-03 07:57:21.92 | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION | root@localhost | utf8 | utf8_general_ci | utf8_general_ci |
    +---------+--------+-------+-------------------------------------------------------------------+--------+------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+----------------+----------------------+----------------------+--------------------+
    2 rows in set (0.00 sec)

  • 相关阅读:
    有限状态机(FSM)的简单理解和Python实现
    【Papers】Lane-Detection 近期车道线检测论文阅读总结
    刷LeetCode的简易姿势
    数码时代的效率生活
    轻量化模型训练加速的思考(Pytorch实现)
    编程之美!从线程池状态管理来看二进制操作之美
    没想到,Git居然有3种“后悔药”!
    交易系统高并发下的幂等性设计原则
    集群环境中使用Zookeeper实现分布式幂等控制
    Elasticsearch 入门到高手的成长阶梯-索引的基本操作(2)-索引的收缩和拆分
  • 原文地址:https://www.cnblogs.com/ayanboke/p/10965579.html
Copyright © 2011-2022 走看看