数据库修复Part1:创建自己的测试corrupt数据库
以前看Pual寫過很多數據恢復的文章,他很多的測試都是自己創建的Corrupt數據庫,其實我們自己也可以。
?
1. 創建數據庫數據表插入數據:
use master
go
create databasecorrupt
?
use corrupt
go
create tabletest(IDint, namevarchar(10))
?
declare @int asint
set @int = 1
while @int <20
begin
insert intotestvalues(@int,'allentest')
set @int += 1
end
?
2. 使用DBCC IND查看Test表所在的PageID
dbcc ind(corrupt,test,1)
?
?
3. 用DBCC PAGE查看TEST表的內容:
dbcc traceon(3604,-1)
go
dbcc page(corrupt,1,55,1)
?
?
?
這里我們只修改Slot 1數據,偏移地址為78,轉化為10進制為120.
所以當前Slot1的實際地址為:55*8192+120=450680
?
4. 停掉SQL Server用XVI32打開數據文件然后輸入地址找到對應的數據(可以看到數據與Step3中看到的數據一致)。
?
?
?
5. 對數據進行修改保存關閉XVI32。
?
6. 重啟SQL Server然后用DBCC PAGE看Page 55 Slot1內容(已經被更改)
7. DBCCCHECKDB檢查數據庫發現下面的錯誤:
?
dbcc checkdb withno_infomsgs
?
Msg8928, Level 16, State 1, Line 1
Object ID2105058535, index ID 0, partition ID 72057594038779904, alloc unit ID72057594039828480 (type In-row data): Page (1:55) could not be processed. See other errors for details.
Msg8939, Level 16, State 98, Line 1
Table error: ObjectID 2105058535, index ID 0, partition ID 72057594038779904, alloc unit ID72057594039828480 (type In-row data), page (1:55). Test (IS_OFF (BUF_IOERR,pBUF->bstat)) failed. Values are 12716041 and -4.
這樣我們就創建了一個Corrupt的數據庫,稍后我會花時間測試恢復(page restore/ dbcc checkdbrepair_allow_data_loss/rebuildSQL Server log),然后把測試步驟發出來.
?
如果你不想自己創建的話,也可以使用Paul提供的兩個Corrupt數據庫做測試。
轉載于:https://blog.51cto.com/lzf328/954147
總結
以上是生活随笔為你收集整理的数据库修复Part1:创建自己的测试corrupt数据库的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: HDU 4339 Query
- 下一篇: 恋人咒语