关于mysql中insert、update、delete的触发器(跨库操作)



--新增触发器
drop trigger if exists test_zwd;
delimiter//
create trigger test_zwd
after insert on platformbackstage.t_oper_keywords_copy
for each row
begin
 insert into baseForReptile.t_oper_keywords_copy(id,columnId,platFormIds,name,note,`order`,isUsed,createUserId,lastModifyUserId,createTime,lastModifyTime)
 values(new.id,new.columnId,new.platFormIds,new.name,new.note,new.`order`,new.isUsed,new.createUserId,new.lastModifyUserId,new.createTime,new.lastModifyTime);
end;
//
delimiter;


--删除触发器
drop trigger if exists test_zwd_delete;
delimiter//
create trigger test_zwd_delete
 after delete on platformbackstage.t_oper_keywords_copy
for each row
begin
 delete from baseForReptile.t_oper_keywords_copy where id = old.id;
end;
//
delimiter;



--修改的触发器
drop trigger if exists test_zwd_update;
delimiter//
create
 trigger test_zwd_update
 before update
 on platformbackstage.t_oper_keywords_copy
 for each row
 begin
 update baseForReptile.t_oper_keywords_copy set id=new.id,columnId=new.columnId,platFormIds=new.platFormIds,name=new.name,note=new.note,`order`=new.`order`,isUsed=new.isUsed,createUserId=new.createUserId,lastModifyUserId=new.lastModifyUserId,createTime=new.createTime,lastModifyTime=new.lastModifyTime where id = old.id;
 end;
//
delimiter;

你可能感兴趣的:(mysql,跨库操作,触发器,同步执行数据操作)