CREATE TABLE `NewTable` (
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT ,
`name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`pwd` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
PRIMARY KEY (`id`)
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci
AUTO_INCREMENT=7
ROW_FORMAT=COMPACT
;
CREATE DEFINER=`root`@`localhost` TRIGGER `add` AFTER INSERT ON `NewTable`
FOR EACH ROW BEGIN
insert into ht_log (logtime,content) values (NOW(),CONCAT('添加用户',new.name));
END;
CREATE DEFINER=`root`@`localhost` TRIGGER `update` AFTER UPDATE ON `NewTable`
FOR EACH ROW BEGIN
insert into ht_log (logtime,content) values (NOW(),CONCAT('修改用户',old.name,'->',new.name,';',old.pwd,'->',new.pwd));
END;
CREATE DEFINER=`root`@`localhost` TRIGGER `delete` AFTER DELETE ON `NewTable`
FOR EACH ROW BEGIN
insert into ht_log (logtime,content) values (NOW(),CONCAT('删除用户',old.name));
END;