HelloDBA [中文]
Search Internet Search HelloDBA
  Oracle Technology Site. email: fuyuncat@gmail.com  MSN: fuyuncat@hotmail.com Add to circle  acoug  acoug 

Fy_Recover_Data 2014.03.07 Update -- You can recover truncated table from offline data files now

[中文]

Author:  fuyuncat

Source:  www.HelloDBA.com

Date:  2016-03-07 01:52:17

Share to  Twitter Facebook GMail Blogger Orkut Google Bookmarks Sina Weibo QQ Renren Tieba Kaixin Douban Taobao

  -- 05/03/2014, Fuyuncat:                                                ---

  •   --   1. Fixed bugs                                                      ---
  •   --   2. Use existing dirctory if applicable                             ---
  •   --   3. Recover data from offline files                                 ---

In case you found that you truncated a table should not be done. You may copy the data files of the tablespace to a local location. And then use Fy_Recover_Data to recover data from those offline files. This will guarantee minimuming data lost. (Bear in mind, once table is truncated, the data blocks will be reclaimed by Oracle immediately, and you might be allocated to other objects if necessary.) 

SQL代码
  1. ASMCMD> cp data1/dbat1/datafile/ASM_DATA.360.839931591 /tmp/ams_data.dat  
  2. copying +data1/dbat1/datafile/ASM_DATA.360.839931591 -> /tmp/ams_data.dat  
  3. ASMCMD> exit  
  4.   
  5. oracle@dbsvr:dbat1:> sqlplus / as sysdba  
  6. SQL*Plus: Release 11.2.0.3.0 Production on Fri Mar 7 12:48:45 2014  
  7.   
  8. Copyright (c) 1982, 2011, Oracle.  All rights reserved.  
  9.   
  10.   
  11. Connected to:  
  12. Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production  
  13. With the Partitioning, Automatic Storage Management, OLAP, Data Mining  
  14. and Real Application Testing options  
  15.   
  16. HelloDBA.COM> !cp /u01/app/oracle/oradata/dbat1/asm_data_fs.dat /tmp/asm_data_2  
  17.   
  18. HelloDBA.COM> exec fy_recover_data.recover_truncated_table('SYS','T1',1,'/tmp','/tmp/asm_data_1;/tmp/asm_data_2;');  
  19. 16:06:27: Use existing Directory Name: FY_DATA_DIR  
  20. 16:06:28: Recover Table: SYS.T1$  
  21. 16:06:28: Restore Table: SYS.T1$$  
  22. 16:06:43: Copy file of Recover Tablespace: FY_REC_DATA_COPY.DAT2  
  23. 16:06:43: begin to recover table SYS.T1  
  24. 16:06:43: Use existing Directory Name: TMP_HF_DIR  
  25. 16:06:44: Recovering data in datafile /tmp/asm_data_1  
  26. 16:06:44: Use existing Directory Name: FY_DATA_DIR  
  27. 16:06:49: 153 truncated data blocks found.  
  28. 16:06:49: 4348 records recovered in backup table SYS.T1$$  
  29. 16:06:49: Recovering data in datafile /tmp/asm_data_2  
  30. 16:06:49: Use existing Directory Name: FY_DATA_DIR  
  31. 16:06:50: 0 truncated data blocks found.  
  32. 16:06:50: 0 records recovered in backup table SYS.T1$$  
  33. 16:06:50: Total: 153 truncated data blocks found.  
  34. 16:06:50: Total: 4348 records recovered in backup table SYS.T1$$  
  35. 16:06:50: Recovery completed.  
  36. 16:06:50: Data has been recovered to SYS.T1$$  
  37.   
  38. PL/SQL procedure successfully completed.  

Click Here to download source code of the package.

 

--- Fuyuncat ---

Top

Copyright ©2005, HelloDBA.Com All reseverd.

Declaration
by fuyuncat