Mysql 同步触发器

Mysql 同步触发器

use shumei

DELIMITER //
CREATE TRIGGER tr_Insert_t1
  AFTER INSERT ON video
FOR EACH ROW
BEGIN
  -- 检查前 环境避免递归.
  IF @disable_trigger IS NULL THEN
    -- 设置禁用触发器标志.
    SET @disable_trigger = 1;
    -- 插入目标表
    INSERT INTO
      f_video.video
    VALUES
      (new.video_id,new.vv_id,new.admin_id,new.video_style,new.video_type,new.title,new.description,new.video_img_url,new.video_url,new.video_small_url,new.video_keyword,new.video_data,new.video_memo,new.video_recommend,new.update_time,new.create_time,new.status);
    -- 恢复禁用触发器标志.
    SET @disable_trigger = NULL;
  END IF;
END;
//
DELIMITER ;

use f_video

DELIMITER //
CREATE TRIGGER tr_Insert_t2
  AFTER INSERT ON video
FOR EACH ROW
BEGIN
  -- 检查前 环境避免递归.
  IF @disable_trigger IS NULL THEN
    -- 设置禁用触发器标志.
    SET @disable_trigger = 1;
    -- 插入目标表
    INSERT INTO
      shumei.video
    VALUES
      (new.video_id,new.vv_id,new.admin_id,new.video_style,new.video_type,new.title,new.description,new.video_img_url,new.video_url,new.video_small_url,new.video_keyword,new.video_data,new.video_memo,new.video_recommend,new.update_time,new.create_time,new.status);
    -- 恢复禁用触发器标志.
    SET @disable_trigger = NULL;
  END IF;
END;
//
DELIMITER ;
# Mysql   同步  

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×