SQL Server簡單模式下誤刪除堆表記錄恢復方法(繞過
導讀:1建站知識這篇主旨是揭示堆表的刪除記錄找回的原理,我所考慮的方面并不適用于每個人的每種情況,望大家見諒網站seo優化網站seo優化診斷工具。
首先,我需要強調下,這篇主旨是揭示堆表的刪除記錄找回的原理,我所考慮的方面并不適用于每個人的每種情況,望大家見諒~ 很多朋友認為數據庫在簡單模式下,堆表誤刪除一條記錄,是無法找回的,因為沒有日志記錄。其實不然,某種意義上是可以找回的,因為堆表在刪除記錄時,只更改了行偏移,實際數據沒有被物理刪除,所以利用這點,測試了下恢復數據,果然成功了,但是還有點問題沒有研究出結果:如果不關閉頁面校驗,除了更改偏移量,刪除數據時還需要更改頁眉,這點還沒時間去琢磨,所以恢復數據時還要能推斷出頁眉的16進制對應關系,有興趣的朋友可以分享下經驗給我。這里為了排除頁眉的校驗錯誤,關閉后測試 廢話不多說,測試的demo如下: 測試環境: SQL Server 2008 R2 數據庫:repl_test 簡單模式 測試表:test_del 測試步驟 1.創建測試表test_del,并插入測試數據。
復制代碼 代碼如下:
create table test_del( a int identity,b char(10)) go insert into test_del select 'row 1'; insert into test_del select 'row 2'; insert into test_del select 'row 3'; insert into test_del select 'row 4'; insert into test_del select 'row 5'; go
2.查看測試數據,顯示正常。 3.DBCC IND命令來找到數據頁id,找到數據頁id:219,這個數據頁存放了test_del的數據 使用dbcc page查看數據頁的內容以及行偏移量 dbcc page(repl_test,1,219,1) go輸出結果為: DATA: Slot 0, Offset 0x60, Length 21, DumpStyle BYTE Record Type = PRIMARY_RECORD Record Attributes = NULL_BITMAP Record Size = 21 Memory Dump @0x00000000120CC060 0000000000000000: 10001200 01000000 726f7720 31202020 †........row 1 0000000000000010: 20200200 00†††††††††††††††††††††††††† ... Slot 1, Offset 0x75, Length 21, DumpStyle BYTE Record Type = PRIMARY_RECORD Record Attributes = NULL_BITMAP Record Size = 21 Memory Dump @0x00000000120CC075 0000000000000000: 10001200 02000000 726f7720 32202020 †........row 2 0000000000000010: 20200200 00††††††††††††††††††營銷型網站建設8224;††††††† ... Slot 2, Offset 0x8a, Length 21, DumpStyle BYTE Record Type = PRIMARY_RECORD Record Attributes = NULL_BITMAP Record Size = 21 Memory Dump @網站建設制作0x00000000120CC08A 0000000000000000: 10001200 03000000 726f7720 33202020 †........row 3 0000000000000010:網站推廣優化seo 20200200 00†††††††††††††††††††††††††† ... Slot 3, Offset 0x9f, Length 21, DumpStyle BYTE Record Type = PRIMARY_RECORD Record Attributes = NULL_BITMAP Record Size = 21 Memory Dump @0x00000000120CC09F 0000000000000000: 10001200 04000000 726f7720 34202020 †........row 4 0000000000000010: 20200200 00†††††††††††††††††††††††††† ... Slot 4, Offset 0xb4, Length 21, DumpStyle BYTE Record Type = PRIMARY_RECORD Record Attributes = NULL_BITMAP Record Size = 21 Memory Dump @0x00000000120CC0B4 0000000000000000: 10001200 05000000 726f7720 35202020 †........row 5 0000000000000010: 20200200 00†††††††††††††††††††††††††† ... OFFSET TABLE: Row - Offset 4 (0x4) - 180 (0xb4) 3 (0x3) - 159 (0x9f) 2 (0x2) - 138 (0x8a) 1 (0x1) - 117 (0x75) 0 (0x0) - 96 (0x60) 其中行偏移量第一行為96 (0x60),實際記錄為row 1,row 2: (0x75),row 3: (0x8a),row 4:(0x9f),row 5: (0xb4) 4. 刪除第三行數據 a = 3,b = row 3的記錄聲明: 本文由我的SEOUC技術文章主頁發布于:2023-05-23 ,文章SQL Server簡單模式下誤刪除堆表記錄恢復方法(繞過主要講述表記,頁眉,SQL網站建設源碼以及服務器配置搭建相關技術文章。轉載請保留鏈接: http://www.bifwcx.com/article/web_6024.html