我要写一个触发器
假如有一个a 表保存的一些重要的数据
b 表保存了一些关于对a表数据update的历史记录
b 表字段有 a表被改的字段名,原来数据,新数据
可以实用吗??

解决方案 »

  1.   

    完全可以实现
    写一个行级触发器就可以了
    用new.***  old.***
      

  2.   

    create or replace trigger a_tri 
    before insert or update on a
    for each row
    begin
    if insertint then
    insert into b values(:new.col_name,...);
    else
    insert into b values(:new.col_name,...);
    insert into b values(:old.col_name,...);
    end if;
    end;
    /
      

  3.   

    谢谢各位的回答,那在我在触发器中可不可以得到是update了a表那个字段呢?
      

  4.   

    可以在beckhambobo(beckham) 的方法加入
    if :old.col_name1=:new.col_name1的判断语句得到被修改的字段名