注意事项
恢复被delete删除的数据,删除时间点很关键,orcle所在服务器的时间和真实时间可能不同。
比如,你在自己电脑显示时间为2022/10/13 10:15:02时,误删了数据,而此时orcle服务器时间为2022/10/12 21:15:02,那么恢复数据时应该使用2022/10/12 21:15:02作为删除时间点。
如果时间有误(指定的删除时间点,晚于orcle所在服务器的当前系统时间时),可能会提示:ORA-08186: invalid timestamp specified
恢复被delete的数据
全部数据恢复
直接插入删除前的数据
例子:不小心把test_recycle表的数据全部delete删除掉了,查出指定时间时该表的数据(删除前的时间,注意oracle所处服务器时间可能和你电脑的系统时间不一样),重新插入数据到表insert into test_recycle ( select * from test_recycle as of timestamp to_timestamp('2022-10-11 09:11:00','yyyy-mm-dd hh24:mi:ss'))
部分数据恢复
情况1:如果还保留着delete语句,知道误删了哪些数据和删除的时间点
delete from test_recycle where name = 'a' insert into test_recycle ( select * from test_recycle as of timestamp to_timestamp('2022-10-11 5:41:00','yyyy-mm-dd hh24:mi:ss') where name = 'a') -- 代入删除时的where条件
情况2:只知道删除的时间点
以唯一索引作为数据的唯一身份标识,将删除前有但是当前没有的数据重新插入到表
insert into test_recycle ( select * from test_recycle as of timestamp to_timestamp('2022-10-11 5:41:00','yyyy-mm-dd hh24:mi:ss') where id not in(select id from test_recycle) )
恢复被drop的表,并恢复数据到drop前
查出被drop表的object_name
select * from user_recyclebin t order by t.droptime desc -- object_name:BIN$6r/mywqrLI/gVUgfhvyykg==$0
恢复
flashback Table "BIN$6r/mywqrLI/gVUgfhvyykg==$0" to before drop;
参考资料
https://blog.csdn.net/zhannabiedong/article/details/124441818
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 2025年我用 Compose 写了一个 Todo App
· 张高兴的大模型开发实战:(一)使用 Selenium 进行网页爬虫