oracle恢复删除数据
2015-08-24 16:05
399 查看
分为两种方法:scn和时间戳两种方法恢复。
一、通过scn恢复删除且已提交的数据
1、获得当前数据库的scn号
select current_scn from v$database; (切换到sys用户或system用户查询)
查询到的scn号为:1499223
2、查询当前scn号之前的scn
select * from 表名 as of scn 1499220; (确定删除的数据是否存在,如果存在,则恢复数据;如果不是,则继续缩小scn号)
( 报错:ORA-08189: cannot flashback the table because row movement is not enabled)
alter table 表名 enable row movement;
3、恢复删除且已提交的数据
flashback table 表名 to scn 1499220;
二、通过时间恢复删除且已提交的数据
1、查询当前系统时间
select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;
2、查询删除数据的时间点的数据
select * from 表名 as of timestamp to_timestamp('2013-05-29 15:29:00','yyyy-mm-dd hh24:mi:ss'); (如果不是,则继续缩小范围)
3、恢复删除且已提交的数据
flashback table 表名 to timestamp to_timestamp('2013-05-29 15:29:00','yyyy-mm-dd hh24:mi:ss');
注意:如果在执行上面的语句,出现错误。可以尝试执行 alter table 表名 enable row movement; //允许更改时间戳
一、通过scn恢复删除且已提交的数据
1、获得当前数据库的scn号
select current_scn from v$database; (切换到sys用户或system用户查询)
查询到的scn号为:1499223
2、查询当前scn号之前的scn
select * from 表名 as of scn 1499220; (确定删除的数据是否存在,如果存在,则恢复数据;如果不是,则继续缩小scn号)
( 报错:ORA-08189: cannot flashback the table because row movement is not enabled)
alter table 表名 enable row movement;
3、恢复删除且已提交的数据
flashback table 表名 to scn 1499220;
二、通过时间恢复删除且已提交的数据
1、查询当前系统时间
select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;
2、查询删除数据的时间点的数据
select * from 表名 as of timestamp to_timestamp('2013-05-29 15:29:00','yyyy-mm-dd hh24:mi:ss'); (如果不是,则继续缩小范围)
3、恢复删除且已提交的数据
flashback table 表名 to timestamp to_timestamp('2013-05-29 15:29:00','yyyy-mm-dd hh24:mi:ss');
注意:如果在执行上面的语句,出现错误。可以尝试执行 alter table 表名 enable row movement; //允许更改时间戳
相关文章推荐
- ssma for oracle
- Oracle数据库启动和关闭方式
- ORACLE sql 判断字段中某个字符出现次数
- oracle中无法查询中文条件
- 一个Oracle循环例子
- Oracle修改字段类型方法总结
- 如何在Windows下利用Oracle VM VirtualBox虚拟机下安装linux
- 【Java EE 学习 29 下】【JDBC编程中操作Oracle数据库】【调用存储过程的方法】
- oracle怎样删除回收站里面的表
- oracle学习笔记一:用户管理(2)创建删除用户
- pl sql连接oracle报错12154-解决X64操作系统PL/SQL连接报错问题 make sure you have the 32 bits oracle client installed
- oracle 索引的(创建、简介、技巧、怎样查看)
- oracle 、sql server、mysql 日期转字符串:convert、to_char、date_forma
- 【DATAGUARD】物理dg在主库丢失归档文件的情况下的恢复(七)
- oracle中in 和exists的使用效率
- 如何利用JDBC连接并操作Oracle数据库
- oracle数据库
- Oracle中的索引详解
- oracle中trim,ltrim,rtrim函数用法
- oracle 估算undo脚本