在误删除表中数据后,并已经提交事务的情况下,立即闪回恢复
实验例子:
--oracle闪回,前提是数据库开了闪回功能
1.查询一张表
select * from user_profile;
2.删除这样表中id为5的这条数据,并提交事务
delete from user_profile where id=5;
commit;
3.查询表确认删除
select * from user_profile;
4.开始闪回
--select to_char(sysdate, 'yyyy-mm-dd hh24:mi:ss') time, to_char(dbms_flashback.get_system_change_number) scn from dual;
--
select * from user_profile as of timestamp to_timestamp('2024-04-11 10:47:47', 'yyyy-mm-dd hh24:mi:ss');
--
将查到的数据插入临时表
create table tab_test01 as
select * from user_profile as of timestamp to_timestamp('2024-04-11 10:47:47', 'yyyy-mm-dd hh24:mi:ss');
--将之前删除的数据插入到原表中
select * from tab_test01;
insert into user_profile select * from tab_test01 where id=5;
--再次查看是否还原成功-一般没问题
select * from user_profile;