表误删记录恢复操作
表误删记录恢复操作 最近处理了个用户误删delete table 的故障,这里做了一个简单的汇总,文章内容整理自pub 里的各位大师的精粹,我这里偷个懒直接拿来用下。 基本处理思路: 1.如果还没有提交,用rollback。(应该不大可能。) 2.如果提交时间超过5分钟以
表误删记录恢复操作
最近处理了个用户误删delete table 的故障,这里做了一个简单的汇总,文章内容整理自pub 里的各位大师的精粹,我这里偷个懒直接拿来用下。
基本处理思路:
1.如果还没有提交,用rollback。(应该不大可能。)
2.如果提交时间超过5分钟以上且小于undo_retention的设置,可以使用回闪功能。具体限制和操作可以参考:http://blog.itpub.net/post/468/15464
3.如果上述两条都不满足,可以使用logminer从redo中恢复,logminer的使用限制和描述可以参考:http://blog.itpub.net/post/468/13436
这里有一个使用logminer的简单的例子:http://blog.itpub.net/post/468/11764
4.如果这个日志已经重用且没有启用归档模式,那么你只能从备份中恢复了
2.使用闪回恢复表数据
2.1----flashback table
主要是是用undo 表空间的内容
注意:需要启用表的row movement
----格式化时间
SQL> alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
SQL> select sysdate from dual;
SYSDATE
-------------------
2014-07-27 20:23:37
----enable row movement
Alter table xxx enable row movement:
----根据scn 闪回表:
SQL> flashback table kel.t1 to scn 896744;
---根据时间点闪回表:
SQL> flashback table kel.t1 to timestamp to_timestamp('2014-07-28 00:18:00','yyyy-mm-dd hh24:mi:ss');
2.2----flashback query:
flashback query只能看到某一个时间点的对象的状态,而不能看到某个时间段内的状态变化。
select * from tb as of timestamp to_timestamp('2014-07-27 20:23:37','yyyy-mm-dd hh24:mi:ss');
2.3-----flashback drop
用于恢复用户误删除的对象,包括表、索引等,依赖于tablespace recycle bin ,表空间回收站
初始化参数recyclebin参数用于控制是否启用recyclebin功能,缺省是ON
在recycle bin中,oracle可以区分不同用户的同名的表。
recycle bin的维护:
1、只能用于非系统表空间和本地管理的表空间
2、如果对象创建在本地管理的表空间,而关联对象,比如索引创建在字典管理的表空间上,则恢复时字段管理的表空间关联对象不能被恢复
3、对象是否能恢复成功,取决于对象空间是否被覆盖重用
4、不能对recycle bin中的内容进行DML和DDL的操作,只能做查询操作
5、对象的参考约束不能被恢复,也就是外键约束需要重建
手动清除recycle bin的空间:
purge tablespace kel
db_flashback_retention_target Default value 1440 (minutes)
闪回查询使用的是undo 信息
UNDO_RETENTION 理解:
The UNDO_RETENTION parameter is ignored for a fixed size undo tablespace. The database may overwrite unexpired undo information when tablespace space becomes low.
如果undo 表空间大小是固定的,则oracle会忽略 undo_retention 参数的设置,在undo 空间不足的情况下,oracle可能会覆盖未过期的undo 信息。
For an undo tablespace with the AUTOEXTEND option enabled, the database attempts to honor the minimum retention period specified by UNDO_RETENTION. When space is low, instead of overwriting unexpired undo information, the tablespace auto-extends. If the MAXSIZE clause is specified for an auto-extending undo tablespace, when the maximum size is reached, the database may begin to overwrite unexpired undo information.
当undo 是自动扩展的,oracle 会尽可能的保证 undo_retention 设置的undo保留时间;当undo 空间不够使oracle 会优先自动扩展undo 表空间,而不是去覆盖未过期的undo 信息,如果undo tbs 设置了 maxsize 参数,则在达到undo最大空间时,oracle可能就会去覆盖那些未过期的undo信息。
注意:对于在system表空间的中对象,使用闪回drop 无效,因为被drop的对象不会被放在 recyclebin 中:
----确认是否启用recyclebin功能
SQL> show parameter recyclebin
----可以通过视图来进行查看recycle bin中的对象列表:
select object_name as recycle_name,original_name from recyclebin;
----可以像查看普通表一样,来查看recycle bin 中对象的内容:
select count(*) from "BIN$/ti6DA4axIDgQKjAbgFLmA==$0";
要使用flashback drop功能恢复误删除的表,需要做以下几点:
1、确认已删除的表在recycle bin中
2、使用flashback table来进行恢复
如果同名的表在recycle bin中存在,可以恢复到需要的那个表:
select count(*) from "BIN$/ti6DA4cxIDgQKjAbgFLmA==$0";--查看哪个是想恢复的表
---恢复表
flashback table "BIN$/ti6DA4exIDgQKjAbgFLmA==$0" to before drop;
---恢复表并且重命名为kel1
flashback table kel to before drop rename to kel1;
3.使用oracle logminer 来进行数据恢复:
logmnr其实是非常有用的一个恢复数据的工具,今天有人提到恢复700万的数据,我也做过几万条财务数据的恢复,借此小结一下。
--创建一个表来保存提取出来的sql
create table logmnr_content tablespace tools as select scn,cscn,TIMESTAMP,sql_undo from v$logmnr_contents where 1=0;
--通过dba_objects 查到表对应的 object_id and data_object_id ,用来在log中提取该表相关的sql_undo
select object_id,data_object_id from dba_objects where object_name = ???
--通过在os中找到的归档日志范围,进行联机提取
将undo sql 插入一个表中,比如我的日志序号范围是 5813 到 5850
为了防止临时空间不足,一个一个归档日志文件处理。
begin
for i in 8..24 loop
dbms_logmnr.add_logfile(LogFileName=>'/disk2/oradata/arch/crmcn/crmcn_1_'||i||'.arc');
dbms_logmnr.start_logmnr(Options => sys.dbms_logmnr.DICT_FROM_ONLINE_CATALOG);
dbms_logmnr.start_logmnr();
insert into logmnr_content(scn,cscn,TIMESTAMP,sql_undo )
select scn,cscn,TIMESTAMP,sql_undo from v$logmnr_contents
where DATA_OBJD# = 52528;
commit;
dbms_logmnr.end_logmnr();
end loop;
end
/
--将提取出来的sql通过动态sql执行插入表
declare
sql_str varchar2(4000);
begin
for c in (select * from logmnr_content) loop
sql_str := replace(c.sql_undo,';','');
execute immediate sql_str;
end loop;
commit;
end;
注意:如果在这段日志中还有其他对该表的操作的话,可以结合操作类型 OPERATION 和提交scn cscn 来判断到底是不是该恢复的这部分数据。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Pinduoduo software provides a lot of good products, you can buy them anytime and anywhere, and the quality of each product is strictly controlled, every product is genuine, and there are many preferential shopping discounts, allowing everyone to shop online Simply can not stop. Enter your mobile phone number to log in online, add multiple delivery addresses and contact information online, and check the latest logistics trends at any time. Product sections of different categories are open, search and swipe up and down to purchase and place orders, and experience convenience without leaving home. With the online shopping service, you can also view all purchase records, including the goods you have purchased, and receive dozens of shopping red envelopes and coupons for free. Now the editor has provided Pinduoduo users with a detailed online way to view purchased product records. method. 1. Open your phone and click on the Pinduoduo icon.

1. First, we right-click the blank space of the taskbar and select the [Task Manager] option, or right-click the start logo, and then select the [Task Manager] option. 2. In the opened Task Manager interface, we click the [Services] tab on the far right. 3. In the opened [Service] tab, click the [Open Service] option below. 4. In the [Services] window that opens, right-click the [InternetConnectionSharing(ICS)] service, and then select the [Properties] option. 5. In the properties window that opens, change [Open with] to [Disabled], click [Apply] and then click [OK]. 6. Click the start logo, then click the shutdown button, select [Restart], and complete the computer restart.

On Douyin, a short video platform full of creativity and vitality, we can not only enjoy a variety of exciting content, but also have in-depth communications with like-minded friends. Among them, chat sparks are an important indicator of the intensity of interaction between the two parties, and they often inadvertently ignite the emotional bonds between us and our friends. However, sometimes due to some reasons, the chat spark may be disconnected. So what should we do if we want to restore the chat spark? This tutorial guide will bring you a detailed introduction to the content strategy, hoping to help everyone. How to restore the spark of Douyin chat? 1. Open the Douyin message page and select a friend to chat. 2. Send messages and chat to each other. 3. If you send messages continuously for 3 days, you can get the spark logo. On a 3-day basis, send pictures or videos to each other

Emmo Diary is a software specially designed for recording your mood. It provides you with a private diary space, allowing you to record important or trivial things every day. Through unique emotion recognition technology, Emmo Diary can also help you better understand and deal with your emotions. But sometimes I find that my diary has been deleted by mistake and I don’t know how to restore it. So this tutorial guide will bring you a detailed recovery guide, hoping to help everyone in need. How can emmo retrieve his previous diary? 1. Click the [Settings] icon in the lower left corner of the emmo selection screen to enter; 2. Select the [Data Backup and Restore] icon on the screen and enter the operation.

LinuxDeploy operating steps and precautions LinuxDeploy is a powerful tool that can help users quickly deploy various Linux distributions on Android devices, allowing users to experience a complete Linux system on their mobile devices. This article will introduce the operating steps and precautions of LinuxDeploy in detail, and provide specific code examples to help readers better use this tool. Operation steps: Install LinuxDeploy: First, install

Xiaohongshu is a popular social e-commerce platform where users can share shopping experiences, life details, etc. During use, some users may experience their comments being deleted. So, how to restore deleted comments on Xiaohongshu? 1. How to restore deleted comments on Xiaohongshu? If it is found that a comment has been deleted by mistake, users can choose to wait for the official Xiaohongshu team to restore it. In this case, it’s best to be patient and wait as the official team may automatically process and resume comments after a while. If you find that a comment has been deleted, consider republishing similar content. But when reposting, please make sure the content complies with Xiaohongshu’s community guidelines to avoid being removed again. 3. Contact Xiaohongshu customer service: If you think your comment has been mistakenly

How to recover deleted sticky notes on Xiaomi mobile phones? Editing notes on Xiaomi mobile phones may accidentally delete them, but most users don’t know how to recover deleted sticky notes. Next is the graphic tutorial on how to recover deleted sticky notes on Xiaomi mobile phones brought by the editor. , interested users come and take a look! Xiaomi mobile phone usage tutorial How to restore deleted Xiaomi mobile phone notes 1. First, use the sticky notes function in Xiaomi mobile phone and enter the main page; 2. Then find the [Notes] guided by the arrow shown in the figure below on the main page; 3. Then it will expand In the function bar, select [Trash]; 4. Then on the Trash function page, find the note file you want to restore and click it; 5. Finally, expand the latest window at the bottom and click [Restore].

Presumably many users have several unused computers at home, and they have completely forgotten the power-on password because they have not been used for a long time, so they would like to know what to do if they forget the password? Then let’s take a look together. What to do if you forget to press F2 for win10 boot password? 1. Press the power button of the computer, and then press F2 when turning on the computer (different computer brands have different buttons to enter the BIOS). 2. In the bios interface, find the security option (the location may be different for different brands of computers). Usually in the settings menu at the top. 3. Then find the SupervisorPassword option and click it. 4. At this time, the user can see his password, and at the same time find the Enabled next to it and switch it to Dis.
