[English]
作者:
fuyuncat
来源:
www.HelloDBA.com
-- 05/03/2014, Fuyuncat: ---
- -- 1. Fixed bugs ---
- -- 2. Use existing dirctory if applicable ---
- -- 3. Recover data from offline files ---
当你不小心truncate了一张表数据后,可以立即将其所在表空间的数据文件拷贝出来。然后利用Fy_Recover_Data的离线数据文件恢复功能恢复数据。这样可以使数据损失降到最低(记住,当表被truncate后,其数据块立即被系统收回,并可能随时被分配给其他对象)。
SQL代码
- ASMCMD> cp data1/dbat1/datafile/ASM_DATA.360.839931591 /tmp/ams_data.dat
- copying +data1/dbat1/datafile/ASM_DATA.360.839931591 -> /tmp/ams_data.dat
- ASMCMD> exit
- oracle@dbsvr:dbat1:> sqlplus / as sysdba
- SQL*Plus: Release 11.2.0.3.0 Production on Fri Mar 7 12:48:45 2014
- Copyright (c) 1982, 2011, Oracle. All rights reserved.
- Connected to:
- Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
- With the Partitioning, Automatic Storage Management, OLAP, Data Mining
- and Real Application Testing options
- HelloDBA.COM> !cp /u01/app/oracle/oradata/dbat1/asm_data_fs.dat /tmp/asm_data_2
- HelloDBA.COM> exec fy_recover_data.recover_truncated_table('SYS','T1',1,'/tmp','/tmp/asm_data_1;/tmp/asm_data_2;');
- 16:06:27: Use existing Directory Name: FY_DATA_DIR
- 16:06:28: Recover Table: SYS.T1$
- 16:06:28: Restore Table: SYS.T1$$
- 16:06:43: Copy file of Recover Tablespace: FY_REC_DATA_COPY.DAT2
- 16:06:43: begin to recover table SYS.T1
- 16:06:43: Use existing Directory Name: TMP_HF_DIR
- 16:06:44: Recovering data in datafile /tmp/asm_data_1
- 16:06:44: Use existing Directory Name: FY_DATA_DIR
- 16:06:49: 153 truncated data blocks found.
- 16:06:49: 4348 records recovered in backup table SYS.T1$$
- 16:06:49: Recovering data in datafile /tmp/asm_data_2
- 16:06:49: Use existing Directory Name: FY_DATA_DIR
- 16:06:50: 0 truncated data blocks found.
- 16:06:50: 0 records recovered in backup table SYS.T1$$
- 16:06:50: Total: 153 truncated data blocks found.
- 16:06:50: Total: 4348 records recovered in backup table SYS.T1$$
- 16:06:50: Recovery completed.
- 16:06:50: Data has been recovered to SYS.T1$$
- PL/SQL procedure successfully completed.
点击此处:下载源代码。
--- Fuyuncat ---