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)

  • 相关阅读:
    百度搜索时加上 (要屏蔽的内容),你会回来感谢我的。
    layui中不全的组件
    PHP使用gd库做的图像处理
    范用户体验相关BLOG
    视频聊天室软件的技术标准
    QTP11使用DOM XPath以及CSS识别元素对象
    跟我一起学Oracle 11g【11】Oracle 中的事务
    一点关于 mybatis 的记录
    git撤销本地commit,复原本地代码与服务器同步
    中国人民银行令〔2021〕第4号(征信业务管理办法)
  • 原文地址:https://www.cnblogs.com/ayanboke/p/10965579.html
Copyright © 2011-2022 走看看