oracle误删除恢复
2015-12-07 14:29
423 查看
create table first_fill_20151207 as
-- 生成到临时表
select * from first_fill
as of timestamp to_timestamp('2015-12-07 07:00:00', 'YYYY-MM-DD HH:MI:SS') ;
分为两种方法:scn和时间戳两种方法恢复。
一、通过scn恢复删除且已提交的数据
1、获得当前数据库的scn号
select current_scn from v$database; (切换到sys用户或system用户查询)
查询到的scn号为:1499223
2、查询当前scn号之前的scn
select * from 表名 as of scn 1499220; (确定删除的数据是否存在,如果存在,则恢复数据;如果不是,则继续缩小scn号)
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; //允许更改时间戳
-- 生成到临时表
select * from first_fill
as of timestamp to_timestamp('2015-12-07 07:00:00', 'YYYY-MM-DD HH:MI:SS') ;
分为两种方法:scn和时间戳两种方法恢复。
一、通过scn恢复删除且已提交的数据
1、获得当前数据库的scn号
select current_scn from v$database; (切换到sys用户或system用户查询)
查询到的scn号为:1499223
2、查询当前scn号之前的scn
select * from 表名 as of scn 1499220; (确定删除的数据是否存在,如果存在,则恢复数据;如果不是,则继续缩小scn号)
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; //允许更改时间戳
相关文章推荐
- 打印所有的Oracle HotSpot JVM参数及其默认值(HotSpot JVM Options/Flags)
- 在单节点上安装 Oracle Grid Infrastructure
- 回顾Oracle几个用到的基本语句
- Oracle数据库横向展示
- ORACLE数据库开发
- Oracle分析函数
- ORACLE ROLLUP和CUBE的使用
- 配置ORACLE 11g绿色版客户端和PLSQL远程连接环境
- Oracle体系结构理解(3)
- oracleLink
- Oracle用户管理(基础)
- Oracle中常见的33个等待事件小结
- Oracle AWR介绍
- oracle学习链接
- ORACLE中的游标Cursor总结
- oracle通过透明网关连接mysql的配置
- oracle数据库无监听程序
- ORACLE恢复删除表或表记录
- oracle 导出、导入
- Oracle的递归查询