#记录插入后的数据 DROP TRIGGER IF EXISTS `after_insert_asset`; #记录更新后的数据 DROP TRIGGER IF EXISTS `after_update_asset`; ##创建触发器 DELIMITER # CREATE DEFINER = `hhit_asset` TRIGGER after_insert_asset AFTER INSERT ON `hhit_asset` FOR EACH ROW BEGIN INSERT INTO `hhit_asset`.`hhit_asset_change_record` ( `ts`, `change_type`, `source_type`, `ip`, `ip_long`, `ipv6`, `ipv6_var` ) VALUES ( NEW.`ts`, 0, NEW.`last_source_type`, NEW.`ip`, NEW.`ip_long`, NEW.`ipv6`, NEW.`ipv6_var` ); END;# DELIMITER ; DELIMITER # CREATE DEFINER = hhit_asset TRIGGER after_update_asset AFTER UPDATE ON `hhit_asset` FOR EACH ROW BEGIN INSERT INTO `hhit_asset`.`hhit_asset_change_record` ( `ts`, `change_type`, `source_type`, `ip`, `ip_long`, `ipv6`, `ipv6_var` ) VALUES ( NEW.`ts`, 1, NEW.`last_source_type`, NEW.`ip`, NEW.`ip_long`, NEW.`ipv6`, NEW.`ipv6_var` ); END;# DELIMITER ;