- 相關(guān)推薦
oracle中truncatetable后的數(shù)據(jù)如何恢復(fù)
Oracle認(rèn)證是由Oracle公司,為能夠滿足對(duì)Oracle核心人士需求,Oracle公司頒布并實(shí)施的一項(xiàng)權(quán)威品的服務(wù)與支持。下面小編為大家整理了關(guān)于oracle中truncatetable后的數(shù)據(jù)如何恢復(fù)的文章,一起來(lái)看看吧:
1、首先下載odu數(shù)據(jù)恢復(fù)工具,然后解壓。(odu工具見附件)
2、查詢數(shù)據(jù)文件路徑相關(guān)信息:select ts#,file#,rfile#,name,BLOCK_SIZE from v$datafile;
將其結(jié)構(gòu)填入odu目錄下的control.txt文件中
格式如下:
#ts #fno #rfno filename block_size
0 1 1 /bbdata/hzdb/system01.dbf 8192
1 2 2 /bbidx/hzdb/undotbs01.dbf 8192
3 3 3 /bbidx/hzdb/indx01.dbf 8192
4 4 4 /bbdata/hzdb/tools01.dbf 8192
5 5 5 /bbdata/hzdb/users01.dbf 8192
6 6 6 /bbdata/hzdb/REPORT.dbf 8192
7 7 7 /bbdata/hzdb/RESERVE.dbf 8192
8 8 8 /bbdata/hzdb/WZHTBS.dbf 8192
9 9 9 /bbdata/hzdb/perfstat01.dbf 8192
3、打開oud
4、執(zhí)行命令:unload dict
5、執(zhí)行命令:scan extent (需等一會(huì)兒時(shí)間)
6、執(zhí)行命令:desc [用戶名].[被刪除數(shù)據(jù)的表名]
Object ID:33547
Storage(Obj#=33547 DataObj#=33549 TS#=11 File#=10 Block#=1400 Cluster=0)
NO. SEG INT Column Name Null? Type
--- --- --- ------------------------------ --------- ------------------------------
1 1 1 OWNER VARCHAR2(30)
2 2 2 OBJECT_NAME VARCHAR2(128)
3 3 3 SUBOBJECT_NAME VARCHAR2(30)
4 4 4 OBJECT_ID NUMBER
5 5 5 DATA_OBJECT_ID NUMBER
6 6 6 OBJECT_TYPE VARCHAR2(18)
7 7 7 CREATED DATE
8 8 8 LAST_DDL_TIME DATE
9 9 9 TIMESTAMP VARCHAR2(19)
10 10 10 STATUS VARCHAR2(7)
11 11 11 TEMPORARY VARCHAR2(1)
12 12 12 GENERATED VARCHAR2(1)
13 13 13 SECONDARY VARCHAR2(1)
從上面的輸出中,我們可以看到,TEST.T1表所在的表空間號(hào)為11,數(shù)據(jù)段頭部為10號(hào)文件的1400號(hào)塊。
我們使用ODU來(lái)確定T1表原來(lái)的data object id。一般來(lái)說(shuō),數(shù)據(jù)段的數(shù)據(jù)塊,一般是在段頭后面相鄰的塊中。但是我們可以從段頭來(lái)確認(rèn):
ODU> dump datafile 10 block 1400
Block Header:
block type=0×23 (ASSM segment header block)
block format=0×02 (oracle 8 or 9)
block rdba=0×02800578 (file#=10, block#=1400)
scn=0×0000.00286f2d, seq=4, tail=0×6f2d2304
block checksum value=0×0=0, flag=0
Data Segment Header:
Extent Control Header
-------------------------------------------------------------
Extent Header:: extents: 1 blocks: 5
last map: 0×00000000 #maps: 0 offset: 668
Highwater:: 0×02800579 (rfile#=10,block#=1401)
ext#: 0 blk#: 3 ext size:5
#blocks in seg. hdr’s freelists: 0
#blocks below: 0
mapblk: 0×00000000 offset: 0
--------------------------------------------------------
Low HighWater Mark :
Highwater:: 0×02800579 ext#: 0 blk#: 3 ext size: 5
#blocks in seg. hdr’s freelists: 0
#blocks below: 0
mapblk 0×00000000 offset: 0
Level 1 BMB for High HWM block: 0×02800576
Level 1 BMB for Low HWM block: 0×02800576
--------------------------------------------------------
Segment Type: 1 nl2: 1 blksz: 2048 fbsz: 0
L2 Array start offset: 0×00000434
First Level 3 BMB: 0×00000000
L2 Hint for inserts: 0×02800577
Last Level 1 BMB: 0×02800576
Last Level 1I BMB: 0×02800577
Last Level 1II BMB: 0×00000000
Map Header:: next 0×00000000 #extents: 1 obj#: 33549 flag: 0×220000000
Extent Map
-------------------------------------------------------------
0×02800576 length: 5
Auxillary Map
-------------------------------------------------------------
Extent 0 : L1 dba: 0×02800576 Data dba: 0×02800579
-------------------------------------------------------------
Second Level Bitmap block DBAs
-------------------------------------------------------------
DBA 1: 0×02800577
從上面的輸出中的“Extent 0 : L1 dba: 0×02800576 Data dba: 0×02800579”可以看到,段的第1個(gè)數(shù)據(jù)塊的RDBA為0×02800579,也就是10號(hào)文件的1401塊。
我們dump第10號(hào)文件的1401塊頭,來(lái)得到表T1原來(lái)的data object id:
ODU> dump datafile 10 block 1401 header
Block Header:
block type=0×06 (table/index/cluster segment data block)
block format=0×02 (oracle 8 or 9)
block rdba=0×02800579 (file#=10, block#=1401)
scn=0×0000.00285f2b, seq=2, tail=0×5f2b0602
block checksum value=0×0=0, flag=0
Data Block Header Dump:
Object id on Block? Y
seg/obj: 0×830b=33547 csc: 0×00.285f21 itc: 3 flg: E typ: 1 (data)
brn: 0 bdba: 0×2800576 ver: 0×01
Itl Xid Uba Flag Lck Scn/Fsc
0×01 0xffff.000.00000000 0×00000000.0000.00 C--- 0 scn 0×0000.00285f21
0×02 0×0000.000.00000000 0×00000000.0000.00 ---- 0 fsc 0×0000.00000000
0×03 0×0000.000.00000000 0×00000000.0000.00 ---- 0 fsc 0×0000.00000000
Data Block Dump:
================
flag=0×0 --------
ntab=1
nrow=16
frre=-1
fsbo=0×32
ffeo=0×145
avsp=0×113
tosp=0×113
可以看到,T1表原來(lái)的data object id就是33547。
7. 使用ODU來(lái)unload數(shù)據(jù):
ODU> unload table test.t1 object 33547
8、使用sqlldr導(dǎo)入我們恢復(fù)的數(shù)據(jù):打開cmd命令,執(zhí)行E:\ODU\data>sqlldr 用戶名/密碼@數(shù)據(jù)庫(kù)id control=TEST_T1.ctl
【oracle中truncatetable后的數(shù)據(jù)如何恢復(fù)】相關(guān)文章:
oracle數(shù)據(jù)庫(kù)基本語(yǔ)句02-08
Oracle數(shù)據(jù)庫(kù)認(rèn)證層次08-29
金蝶軟件如何做好數(shù)據(jù)的備份與恢復(fù)11-29
Oracle數(shù)據(jù)庫(kù)SELECT語(yǔ)句10-25
Oracle數(shù)據(jù)庫(kù)語(yǔ)句大全12-21
oracle數(shù)據(jù)庫(kù)基礎(chǔ)知識(shí)01-21