oracle 恢复


--drop恢复
--根据用户和表名称查询回收站
select * from dba_recyclebin f
 where f.original_name = 'XXXXRECYCLEBIN'
   and f.owner = 'NF_NFZC';
--查出恢复表语句   
select 'create table ' || f.owner || '.recyclebinTABLE003 as  select * from ' ||
       f.owner || '.' || '"' || f.object_name || '";'
  from dba_recyclebin f
 where f.original_name = 'XXXXRECYCLEBIN'
   and f.owner = 'NF_NFZC'
   

--delete恢复
-- =======================根据时间恢复
--查询数据
select * from NF_NFZC.recyclebinTABLE003;
--删除数据
delete from NF_NFZC.recyclebinTABLE003 f where f.devicecode='012963007793321';

--查看当前
select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss')from dual;--2019-01-10 03:04:15
--查看之前的数据  在当前时间上减到自己操作的大概时间 
select * from NF_NFZC.recyclebinTABLE003 as of timestamp to_timestamp('2019-01-10 02:55:23','yyyy-mm-dd hh24:mi:ss');


--执行恢复
flashback table NF_NFZC.recyclebinTABLE003 to timestamp to_timestamp('2019-01-10 02:55:23','yyyy-mm-dd hh24:mi:ss');
--报错ORA-08189:  --1执行 alter table EMP enable row movement;
                   --2insert 删除的数据
                   
-- =======================根据SCN恢复
  select current_scn from v$database;--1656116
  
  
  select * from NF_NFZC.recyclebinTABLE003 as of scn 1656016;
  
  flashback table NF_NFZC.recyclebinTABLE003 to scn 1656016;
  --报错ORA-08189:  --1执行 alter table EMP enable row movement;
                   --2insert 删除的数据

猜你喜欢

转载自blog.csdn.net/qq_30831237/article/details/86220169