救損毀的 ldf

感謝巧玫告知一篇 Paul Randal 有趣的 blog

Creating, detaching, re-attaching, and fixing a suspect database

 

若是要放棄執行非常久的交易,沒耐心而直接關閉 SQL Server Service 後,資料庫仍會長時間處於 recovery,若想要放棄 recovery,基本上,就是砍掉 ldf 後,設定 emergency 和 single_user mode,再讓 dbcc 去救

alter database [AdventureWorks] set emergency

alter database [AdventureWorks] set single_user

dbcc checkdb(‘AdventureWorks’, REPAIR_ALLOW_DATA_LOSS) WITH NO_INFOMSGS, ALL_ERRORMSGS;

如果資料庫超大,這依然會非常久,且會大量耗用 tempdb

 

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 變更 )

Twitter picture

You are commenting using your Twitter account. Log Out / 變更 )

Facebook照片

You are commenting using your Facebook account. Log Out / 變更 )

Google+ photo

You are commenting using your Google+ account. Log Out / 變更 )

連結到 %s

%d 位部落客按了讚: