有这样一个需求,有表t1(id int,code int)、t2(id int,code int),对表t1做数据插入的同时会更新到t2同步,可以通过触发器来实现
mysql触发器:
DELIMITER $$
USE `AAA`$$
DROP TRIGGER /*!50032 IF EXISTS */ `test1`$$
CREATE
/*!50017 DEFINER = 'root'@'localhost' */
TRIGGER `test1` AFTER INSERT ON `t1`
FOR EACH ROW BEGIN
INSERT INTO t2 SET id=new.id,CODE=new.code;
END;
$$
DELIMITER ;
oracle触发器:
create or replace trigger test1
after insert on t1
for each row
declare
-- local variables here
begin
insert into t2(id,code) values(:new.id,:new.code);
end test1;
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26252014/viewspace-756725/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/26252014/viewspace-756725/