Oracle Drop 表数据恢复

利用Oracle 数据回闪机制进行恢复,当一个表被drop掉,表会被放入recyclebin回收站,可通过回收站做表的闪回。表上的索引、约束等同样会被恢复
不支持sys/system用户表空间对象,可通过alter system set recyclebin=off;关闭回收站功能。

Retrieving a Dropped Table: Example If you accidentally drop the pm.print_media table and want to retrieve it, then issue the following statement:

1
FLASHBACK TABLE print_media TO BEFORE DROP;

If another print_media table has been created in the pm schema, then use the RENAME TO clause to rename the retrieved table:

1
FLASHBACK TABLE print_media TO BEFORE DROP RENAME TO print_media_old;

If you know that the employees table has been dropped multiple times, and you want to retrieve the oldest version, then query the USER_RECYLEBIN table to determine the system-generated name, and then use that name in the FLASHBACK TABLE statement. (System-generated names in your database will differ from those shown here.)

1
2
3
4
5
6
7
8
SELECT object_name, droptime FROM user_recyclebin
   WHERE original_name = 'PRINT_MEDIA';
 
OBJECT_NAME                    DROPTIME
------------------------------ -------------------
RB$$45703$TABLE$0              2003-06-03:15:26:39
RB$$45704$TABLE$0              2003-06-12:12:27:27
RB$$45705$TABLE$0              2003-07-08:09:28:01 

 其他回闪语句:

1
2
3
4
5
6
7
8
9
10
11
12
1.闪回数据库
  FLASHBACK DATABASE TO TIMESTAMP to_timestamp('2019-10-14 14:28:33','yyyy-mm-dd HH24:MI:SS');;
  flashback database to scn 16813234;
2.闪回表
  flashback table table_name to scn scn_number;
  flashback table table_name to timestamp to_timestamp('2019-10-14 14:28:33','yyyy-mm-dd hh24:mi:ss');
3.闪回查询
  select * from table_name as of timestamp to_timestamp('2019-10-14 14:28:33','yyyy-mm-dd hh24:mi:ss');
  select * from scott.dept as of scn 16801523;
4.闪回快照
   create restore point before_201910151111 guarantee flashback database;
   flashback database to restore point before_201910151111;

参考:https://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_9012.htm

posted @   西门运维  阅读(1729)  评论(2编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· AI与.NET技术实操系列(六):基于图像分类模型对图像进行分类
历史上的今天:
2018-11-09 AttributeError: module 'pip' has no attribute 'main'
2017-11-09 Ftp服务配置
点击右上角即可分享
微信分享提示