在工作当中有时候根据业务需求需要获取某记录最后一次提交的时间以判断数据是否被修改过或者其他原因;
我们可以利用一个10g版本新增的ora_rowscn函数,得到最后一次提交事务的时间,之后利用函数 scn_to_timestamp转换为timestamp,如下:
select agent_code, scn_to_timestamp(ora_rowscn) ORA_ROWSCN from A where rownum<10;
agent_code ORA_ROWSCN
-------------------- --------------------
M1 2015-05-02 09:18:45
M2 2015-05-02 09:18:45
M22 2015-05-02 09:18:45
M3 2015-05-02 09:18:45
M33 2015-05-02 09:18:45
M39113 2015-05-02 10:08:31
M782 2015-05-02 09:18:45
M527 2015-05-02 09:18:45
M38 2015-05-02 09:18:45
如果此时进行数据update并且commit,则涉及到的数据时间则会更新;
我们可以利用一个10g版本新增的ora_rowscn函数,得到最后一次提交事务的时间,之后利用函数 scn_to_timestamp转换为timestamp,如下:
select agent_code, scn_to_timestamp(ora_rowscn) ORA_ROWSCN from A where rownum<10;
agent_code ORA_ROWSCN
-------------------- --------------------
M1 2015-05-02 09:18:45
M2 2015-05-02 09:18:45
M22 2015-05-02 09:18:45
M3 2015-05-02 09:18:45
M33 2015-05-02 09:18:45
M39113 2015-05-02 10:08:31
M782 2015-05-02 09:18:45
M527 2015-05-02 09:18:45
M38 2015-05-02 09:18:45
如果此时进行数据update并且commit,则涉及到的数据时间则会更新;
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30220976/viewspace-1618216/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/30220976/viewspace-1618216/