现在我有张表tmp,里面有个字段是updatatime,主要是存每次update这条记录时的系统时间。
有没有办法在ORACLE里定义呢?比如这张表有条记录如:
A updatetime
a update tmp set a='b' where A='a' 之后,变成A updatetime
a 2008-10-27 9:46:58
有没有办法在ORACLE里定义呢?比如这张表有条记录如:
A updatetime
a update tmp set a='b' where A='a' 之后,变成A updatetime
a 2008-10-27 9:46:58
set A='b',updatetime=sysdate
where A='a'
1\在你update时将这个字段也update:
update tmp set A = a,updatetime = to_char(sysdate,'yyyy-mm-dd hh24:mi:ss');
commit;
2\写个update 触发器,每次update之后对updatetime作更新.
我的意思是执行update操作的时候,不给updatetime值,也就是说只执行这样的语句
update tmp set a='b' where A='a'
updatetime字段也要出现当时系统时间。
before update on tmp
begin
:new.updatetime:=SYSDATE;
end trg_tmp;
/
update tmp set
A='a',
updatetime=sysdate;