同一库内的两个表,触发器同步:
#增加
delimiter ||
DROP TRIGGER IF EXISTS t_afterinsert_on_tab1 ||
CREATE TRIGGER t_afterinsert_on_tab1
AFTER INSERT ON test1
FOR EACH ROW
BEGIN
insert into test2(id,name,phone) values(new.id,new.name,new.phone);
END||
delimiter ;
#删除
delimiter ||
DROP TRIGGER IF EXISTS t_afterdelete_on_tab1||
CREATE TRIGGER t_afterdelete_on_tab1
AFTER DELETE ON test1
FOR EACH ROW
BEGIN
delete from test2 where id=old.id;
END||
#修改
DELIMITER $
CREATE TRIGGER t_afterupdate_on_tab1
AFTER UPDATE ON test1
FOR EACH ROW
BEGIN
UPDATE test2
SET id = new.id,
name=new.name,
参考:
https://www.duyunwl.cn/2019/03/15/mysql%E8%A1%A8%E5%90%8C%E6%AD%A5/?tdsourcetag=s_pcqq_aiomsg
mysql表同步触发器
2019-03-21 16:32:59
点击:
同一库内的两个表,触发器同步 增加delimiter ||DROP TRIGGER IF EXISTS t_afterinsert_on_tab1 ||CREATE TRIGGER t_afterinsert_o
相关热词搜索:
上一篇:mysql 导入数据出错 Invalid default value
下一篇:mysql设置,取消主键,联合主键
评论排行
- ·Python是美国主流大学最...(5)
- ·HAProxy 配置 HTTP 负载均衡器(1)
- ·Linux+Nginx下SSL证书安装(1)
- ·linux开机自动挂载新硬盘...(1)
- ·linux手动挂载ext盘(1)
- ·mysql修复表,检查表,优...(1)
- ·linux配置网卡(1)
- ·windows下mysql binlog日志开启(1)
- ·Linux创造者Linus Torvalds(1)
- ·关于CentOS 6下Hadoop占...(1)
- ·apache2.4.10 for win 32/64安装教程(1)
- ·运维之家.FAN科技 ...(1)