[中文]
Author:
fuyuncat
Source:
www.HelloDBA.com
Date:
2016-02-19 22:07:41
Fy_Recover_Data can recover the truncated table created on ASM now.
This update includes,
-- 19/02/2014, Fuyuncat: ---
-- 1. Temp Restore and Recover tablespace & files ---
-- will be created on temp folder ---
-- 2. Handle tablespace has files located at diff folders ---
-- 3. Handle tables on ASM ---
A new interface:
SQL代码
- /************************************************************************
- ** recover truncated table
- **
- ** tgtowner: Owner of Target Table to be recovered;
- ** tgttable: Name of Target Table to be recovered;
- ** datapath: Absolute path of Data Files;
- ** fbks: block number to be filled in recovery table;
- ************************************************************************/
- procedure recover_truncated_table( tow varchar2 default 'DEMO',
- ttb varchar2 default 'T_CHAIN',
- fbks number default 1,
- tmppath varchar2 default '/tmp/');
Removed those unnecessary interfaces.
Example:
SQL代码
- HelloDBA.COM> create tablespace asm_data datafile '+DATA1' autoextend on maxsize 1g;
- Tablespace created.
- HelloDBA.COM> create table demo.t_asmtable tablespace asm_data as select * from dba_objects where 1=2;
- Table created.
- HelloDBA.COM> alter tablespace asm_data add datafile '/u01/app/oracle/oradata/dbat1/asm_data_fs.dat' size 100M;
- Tablespace altered.
- HelloDBA.COM> insert into demo.t_asmtable select * from dba_objects;
- 91155 rows created.
- HelloDBA.COM> select count(*) from demo.t_asmtable;
- HelloDBA.COM>
- COUNT(*)
- ----------
- 91155
- HelloDBA.COM> truncate table demo.t_asmtable;
- Table truncated.
- HelloDBA.COM> exec fy_recover_data.recover_truncated_table('DEMO','T_ASMTABLE',1,'/tmp');
- 10:46:55: Directory Name: FY_DATA_DIR2
- 10:46:56: Recover Table: DEMO.T_ASMTABLE$
- 10:46:56: Restore Table: DEMO.T_ASMTABLE$$
- 10:47:08: Copy file of Recover Tablespace: FY_REC_DATA_COPY.DAT
- 10:47:08: begin to recover table DEMO.T_ASMTABLE
- 10:47:09: Directory Name: TMP_HF_DIR
- 10:47:10: Recovering data in datafile /u01/app/oracle/oradata/dbat1/asm_data_fs.dat
- 10:47:10: Directory Name: TMP_DATA_FILE_DIR4
- 10:47:19: 630 truncated data blocks found.
- 10:47:19: 43830 records recovered in backup table DEMO.T_ASMTABLE$$
- 10:47:19: Recovering data in datafile +DATA1/dbat1/datafile/asm_data.360.839931591
- 10:47:19: Directory Name: TMP_DATA_FILE_DIR4
- 10:47:30: 686 truncated data blocks found.
- 10:47:30: 47325 records recovered in backup table DEMO.T_ASMTABLE$$
- 10:47:30: Total: 1316 truncated data blocks found.
- 10:47:30: Total: 91155 records recovered in backup table DEMO.T_ASMTABLE$$
- 10:47:30: Recovery completed.
- 10:47:30: Data has been recovered to DEMO.T_ASMTABLE$$
- PL/SQL procedure successfully completed.
- HelloDBA.COM> select count(*) from DEMO.T_ASMTABLE$$;
- COUNT(*)
- ----------
- 91155
Click Here to download source code of the package.
--- Fuyuncat ---