oracle ora_rowscn

今天,客户说有几个数据表误操作导入了一批新的数据,现在需要把这些数据找出来。

如果没有明显的字段可以识别,那么ora_rowscn可以作为一个参考,以下这个查询就可以通过SCN和数据识别,将后来增加的记录找出来:
SQL> select gro_id,ora_rowscn from bms_group;

    GRO_ID ORA_ROWSCN
---------- ----------
       284  584845289
       322  584845289
       302  584845289
         1  584845289
         3  584845289
         8  584845289
         5  584845289
         6  584845289
         7  584845289
       282  584845289
       362  584845289

    GRO_ID ORA_ROWSCN
---------- ----------
       262  584845289
       342  584845289
       284  612073346
       322  612073346
       302  612073346
         1  612073346
         3  612073346
         8  612073346
         5  612073346
         6  612073346
         7  612073346

    GRO_ID ORA_ROWSCN
---------- ----------
       282  612073346
       362  612073346
       262  612073346
       342  612073346

后者的SCN转换一下,正好是误操作的时间:
SQL> select scn_to_timestamp(612073346) from dual;

SCN_TO_TIMESTAMP(612073346)
---------------------------------------------------------------------------
07-SEP-09 05.11.11.000000000 PM       

而前者的SCN则来自历史时间,可以信赖:
SQL> select scn_to_timestamp(584845289) from dual;

SCN_TO_TIMESTAMP(584845289)
---------------------------------------------------------------------------
03-SEP-09 04.45.13.000000000 PM

-The End-


转自:http://www.eygle.com/archives/2009/09/ora_rowscn.html

发布了161 篇原创文章 · 获赞 17 · 访问量 73万+

猜你喜欢

转载自blog.csdn.net/nanfeiyannan/article/details/42920733
今日推荐