zoukankan      html  css  js  c++  java
  • ORACLE恢复删除的数据

    ---正在执行的

    select a.username, a.sid,b.SQL_TEXT, b.SQL_FULLTEXT
      from v$session a, v$sqlarea b 
    where a.sql_address = b.address 
    ---执行过的
    select b.SQL_TEXT,b.FIRST_LOAD_TIME,b.SQL_FULLTEXT
      from v$sqlarea b
    where b.FIRST_LOAD_TIME between '2009-10-15/09:24:47' and
           '2009-10-15/09:24:47' order by b.FIRST_LOAD_TIME 
    (此方法好处可以查看某一时间段执行过的sql,并且 SQL_FULLTEXT 包含了完整的 sql 语句)

    我用了执行过的语句查询某一时间段自己执行过的sql语句

    转载自:http://blog.163.com/zhb123@126/blog/static/6251585020091171047923/

    删除数据前表中记录
    1> select t.*, t.rowid from vt_temp_test;

    1 1 2 3.00 4.00
    2 5 6 7.00 8.00
    3 9 10 11.00 12.00
    4 13 14 15.00 16.00
     
    记录原数据完整时间点
    2> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;
    1 2009-01-08 09:23:53
     
    删除表中记录
    3> delete from vt_temp_test;
     
    找回原数据完整时间点数据
    4> select * from vt_temp_test as of timestamp to_timestamp('2009-01-08 09:23:53', 'yyyy-mm-dd hh24:mi:ss'); 
    1 1 2 3.00 4.00
    2 5 6 7.00 8.00
    3 9 10 11.00 12.00
    4 13 14 15.00 16.00
     
    插入丢失数据到原表
    5> insert into vt_temp_test select * from vt_temp_test as of timestamp to_timestamp('2009-01-08 09:23:53', 'yyyy-mm-dd hh24:mi:ss');
     
    验证数据恢复情况
    6> select * from vt_temp_test
    1 1 2 3.00 4.00
    2 5 6 7.00 8.00
    3 9 10 11.00 12.00
    4 13 14 15.00 16.00
     
    ---- 此时表明数据已完全恢复到原数据完整时间点的数据 ----

    #### 注:当执行 truncate table vt_temp_test 时,就无法恢复数据,查找当时数据会报错:ORA-01466 unable to read table - table definition has changed。drop table vt_temp_test则更不可恢复 ####
    转载自:http://blog.chinaunix.net/uid-16861721-id-2857492.html
    我自己的用法:
    首先查询某一时间段,自己执行过的sql语句(主要是我delete了一条数据,想要找回)
    1、
    select b.SQL_TEXT,b.FIRST_LOAD_TIME,b.SQL_FULLTEXT
      from v$sqlarea b
    where b.FIRST_LOAD_TIME between '2009-10-15/09:24:47' and
           '2009-10-15/09:24:47' order by b.FIRST_LOAD_TIME
    然后,返回的数据中有我执行过的delete语句,和执行语句的具体时间
    然后,我根据执行语句的具体时间找寻自己这个时间的数据
    2、
    select * from vt_temp_test as of timestamp to_timestamp('2009-01-08 09:23:53', 'yyyy-mm-dd hh24:mi:ss'); 
    然后,将数据插入到原表
    3、
    insert into vt_temp_test select * from vt_temp_test as of timestamp to_timestamp('2009-01-08 09:23:53', 'yyyy-mm-dd hh24:mi:ss');
    4、验证数据恢复情况
    select * from vt_temp_test
  • 相关阅读:
    HDU 4268 multiset
    ACM-线段树
    HDU 5014 异或之和
    HDU 5012 骰子旋转(DFS)
    HDU 5011 NIM博弈
    HDU 5007 字符串匹配
    Android-Context
    Android-视图绘制
    Android-LayoutInflater
    oracle--分页过程demo1
  • 原文地址:https://www.cnblogs.com/zrui-xyu/p/4555050.html
Copyright © 2011-2022 走看看