Oracle查找删除记录后表中某一时间点的数据
2015-10-16 16:08
411 查看
http://blog.chinaunix.net/uid-16861721-id-2857492.html
Oracle查找删除记录后表中某一时间点的数据
------------------------------------------------------------------------------------
删除数据前表中记录
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则更不可恢复 ####
Oracle查找删除记录后表中某一时间点的数据
------------------------------------------------------------------------------------
删除数据前表中记录
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则更不可恢复 ####
相关文章推荐
- ORACLE 动态注册和静态注册的区别(转)
- Oracle ITL(Interested Transaction List)理解
- [甲骨文中国]用全新的数字徽章展示您的Oracle认证!
- Oracle中常用时间操作的汇总
- 深入浅析mybatis oracle BLOB类型字段保存与读取
- Oracle duplicate搭建dataguard (Backup-based duplication)
- oracle开启闪回
- oracle 11G DG物理备库与快照备库的互相转换
- oracle运行失败的类型
- oracle中number数据类型对应java中的基本数据类型
- Oracle递归查询
- ORACLE“监听程序未启动或数据库服务未注册到该监听程序”解决方法
- oracle系统包—-dbms_output用法
- oracle如何导入数据库
- mybatis 调用 oracle 返回结果集 存储过程
- oracle中表中含有的日期字段如何作为筛选条件
- Oracle如何插入在特殊字符: & 和 ' (各种解决方案)
- 成功部署SSIS中含有Oracle数据库连接的ETL包
- 包子的 oracle 学习笔记---触发器
- Oracle 锁与session