zoukankan      html  css  js  c++  java
  • Mysql 触发器笔记

    -- 插入触发器

    DELIMITER //
    create trigger triggerName <after | before> insert on tableName
    FOR EACH ROW
    begin
      if
        begin
          -- new.xx, new.xx (可以拿到插入到表tableName的字段值)
        end
      ELSEIF 
        begin
        end   
    end;//
    DELIMITER ;

    -- 更新触发器

    DELIMITER //
    create trigger triggerName <after | before> update on tableName
    FOR EACH ROW
    Begin
      -- old.xx 代表更新前字段xx的值
      -- new.xx 代表更新后字段xx的值
    END//
    DELIMITER ;

    -- Delete触发器

    DELIMITER //
    create trigger triggerName <after | before> delete on tableName
    FOR EACH ROW
    Begin
      -- old.xx 代表被删除记录字段xx的值
    END//
    DELIMITER ;
    
  • 相关阅读:
    7.12.2
    7.12.1
    7.11.8
    循环测试条件前缀和后缀的区别
    7.11.7 两个版本
    7.11.5
    7.12 vowels.c 程序
    7.11 animals.c 程序
    7.6.2 break 语句
    7.10 break.c 程序
  • 原文地址:https://www.cnblogs.com/stephenzengx/p/14857572.html
Copyright © 2011-2022 走看看