tbl_slope:发生更新的表,
checkupdates:更新后插入数据的表
CREATE trigger updatetbl_slope AFTER update-- 表示触发器是在激活它的语句之后触发 on tbl_slope for each row -- mysql固定语法 BEGIN if EXISTS(SELECT * FROM checkupdates A WHERE A.ID=new.UNIFIEDCODE LIMIT 1) THEN update checkupdates set LastTime=NOW() where TableName='TBL_AVALANCHE' and ID=NEW.UNIFIEDCODE; else insert into checkupdates VALUES(new.UNIFIEDCODE, 'TBL_AVALANCHE', NOW()); END if; END