Mysql 使用触发器,把插入的数据在插入到宁一张表里
CREATE TRIGGER tgr_tablea_insert AFTER //触发器名字 动作在插入数据之后 ON alertinfo //监听哪个表之后触发 FOR INSERT //监听的表的inster操作 AS //sql语句 DECLARE @RuleID CHAR(32),@ImageID CHAR(32),@CameraID CHAR(32), //定义变量 @PersonID INT(10),@Similarity FLOAT ,@AlertTime DATETIME; SELECT @RuleID =RuleID,@ImageID=ImageID, @CameraID=CameraID,@PersonID=PersonID, @Similarity=Similarity,@AlertTime=AlertTime FROM inserted; //把inster的值赋给这些变量 INSERT INTO `attendancealert` (`RuleID`,`ImageID`,`CameraID`,`PersonID`,`Similarity`,`AlertTime`) //最后再插进去 VALUES(@RuleID,@ImageID,@CameraID,@PersonID,@Similarity,@AlertTime); chak
SHOW TRIGGERS
查看所有的触发器
!!