如何用触发器实现表的同步

来源:百度知道 编辑:UC知道 时间:2024/07/04 20:27:59
比如有A,B两张表,当往A表中加入新的数据行时,用触发器如何能把这新的数据行也新增到B表中?

在A表中写一个触发器after insert后
在触发器里面写你要执行的操作
不好意思,现在手头没有例子
只有一个更新的例子
你看看
create or replace trigger trigger_test2
after insert on test2
for each row
declare
aa int;
wrong_no exception;
begin
select count(*) into aa from test3 where xm_id=:new.xm_id;
if aa=0 then
raise wrong_no;
end if;
EXCEPTION
when wrong_no then
DBMS_OUTPUT.PUT_LINE('what are you doing?');
end;