mysql 数据库 trigger 触发器的使用

mysql trigger

触发器的使用

注意前后加加

delimiter $$

....................

$$ delimiter ;

#修改a.dealer  表信息时,更新b.dealer  
delimiter $$
CREATE TRIGGER syncInfoByUpdateA AFTER UPDATE ON A.table1 
FOR EACH ROW BEGIN  

DECLARE  brandid INT(4);
set brandid = (select id from A.brand where uniqueid = NEW.branduniqueid);

update B.table1  
set 
`Name` = NEW.name, 
`BrandId` = brandid, 
`Remark` = `insert trigger`
where uniqueid = NEW.hyuniqueid;

END$$  
delimiter ;

  

posted @ 2022-03-30 01:47  iDEAAM  阅读(64)  评论(0编辑  收藏  举报