博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ORACLE恢复删除的数据
阅读量:4610 次
发布时间:2019-06-09

本文共 2041 字,大约阅读时间需要 6 分钟。

---正在执行的

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

转载于:https://www.cnblogs.com/zrui-xyu/p/4555050.html

你可能感兴趣的文章
JavaScript面试题
查看>>
[转帖]架构师眼中的高并发架构
查看>>
ios的一些开源资源
查看>>
HTTP 错误 500.21 - Internal Server Error 解决方案
查看>>
Bucks sign Sanders to $44 million extension
查看>>
【PHP】Windows下配置用mail()发送邮件
查看>>
人类简史
查看>>
java 设计模式学习
查看>>
【Python使用】使用pip安装卸载Python包(含离线安装Python包)未完成???
查看>>
一语道破项目管理知识体系五大过程组
查看>>
C# 备份、还原、拷贝远程文件夹
查看>>
在windows环境下运行compass文件出现的错误提示解决方案
查看>>
CSS常用样式--font
查看>>
恩如氏--蜗牛精华补水蚕丝面膜
查看>>
大工具-收藏
查看>>
codevs3027 线段覆盖 2
查看>>
markdown
查看>>
【leetcode】107-Binary Tree Level Order Traversal II
查看>>
Jquert data方法获取不到数据,显示为undefined。
查看>>
ssm项目中 数据库和资源的备份
查看>>