2、创建目标数据表:
CREATE TABLE IF NOT EXISTS `test_update` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(50) DEFAULT NULL,
`create_time` date DEFAULT NULL,
`time_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='更新test_trigger后,将数据同步到当前表';
3、触发器:
DROP TRIGGER IF EXISTS test_trigger_update;
CREATE test_trigger_update
AFTER update ON test_trigger
FOR EACH ROW BEGIN insertintotest_update(id,name,create_time)values(old.id,new.insert_name,curdate()); END