oracle 设置闪回-flashback

oracle 设置闪回-flashback

1.查看是否开启闪回:select flashback_on from v$database;
2.开启闪回: alter database flashback on;
3.设置闪回路径: alter system set db_recovery_file_dest='/orcl/app/oracle';
4.设置闪回大小: alter system set db_recovery_file_dest_size='5G';
5.重启数据库: shutdown immediate;  startup;
6.oracle归档默认存储在闪回区,查看归档空间大小: show parameter db_recovery
delete删除的数据闪回
1.查询当前时间: select  to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;
2.查询表test某个时间时的数据: select * from test as of timestamp 
to_timestamp('2021-02-04 18:00:00','yyyy-MM-dd hh24:mi:ss')
3.开启test表行移动功能:alter table test  enable row movement;
4.数据闪回并查看效果: flashback table test to timestamp 
to_timestamp('2021-02-04 18:00:00','yyyy-MM-dd hh24:mi:ss')
数据误删恢复:
oracle查询某个时间点的数据
1.SQL语句是查询某一时间点上的表中的所有数据,可用于恢复误删(全部误删)的数据:
 select * from emps as of timestamp to_Date('2015-12-11 14:00:00','yyyy-mm-dd hh24:mi:ss');
2.恢复误删数据(全部误删)
insert inot emps  select * from emps as of timestamp 
to_Date('2015-12-11 14:00:00','yyyy-mm-dd hh24:mi:ss')
3.恢复部分误删数据(根据主键只插入误删的数据,将表中存在的数据过滤掉):
insert into emp   (select * from emps  as of timestamp to_Date
('2015-12-11 14:00:00','yyyy-mm-dd hh24:mi:ss')  where emp_id not in (select emp_id from emps))
posted @ 2021-09-07 15:57  kht  阅读(841)  评论(0编辑  收藏  举报