现在我有张表tmp,里面有个字段是updatatime,主要是存每次update这条记录时的系统时间。
有没有办法在ORACLE里定义呢?比如这张表有条记录如:
A     updatetime
a     update tmp set a='b' where A='a' 之后,变成A     updatetime
a     2008-10-27 9:46:58

解决方案 »

  1.   

    update tmp set a='b',updatetime=sysdate where A='a'
      

  2.   

    update tmp 
    set A='b',updatetime=sysdate 
    where A='a'
      

  3.   

    两个办法:
    1\在你update时将这个字段也update:
      update tmp set A = a,updatetime = to_char(sysdate,'yyyy-mm-dd hh24:mi:ss');
      commit;
    2\写个update 触发器,每次update之后对updatetime作更新.
      

  4.   

    你们不明白我的意思。
    我的意思是执行update操作的时候,不给updatetime值,也就是说只执行这样的语句
    update tmp set a='b' where A='a' 
    updatetime字段也要出现当时系统时间。
      

  5.   

    写个触发器,在更新A字段后把updatetime也更新了。
      

  6.   

    create or replace trigger trg_tmp
      before update on tmp  
    begin
      :new.updatetime:=SYSDATE;
    end trg_tmp;
    /
      

  7.   


    update tmp set 
              A='a',
              updatetime=sysdate;