Home >Database >Mysql Tutorial >SQLSERVER中修复状态为Suspect的数据库
前几天的Server因断电损坏了DB,DB的Status被标记为 Suspect。 这种情况少见,此时不能Detachp这个DB了,只能Backup。 后面用这些T-Script重建log文件,还是少量数据丟失。 检查DB的状态: 1: SELECT DATABASEPROPERTYEX ( 'DemoSuspect' , 'STATUS' ) AS 'St
前几天的Server因断电损坏了DB,DB的Status被标记为Suspect。这种情况少见,此时不能Detachp这个DB了,只能Backup。
后面用这些T-Script重建log文件,还是少量数据丟失。
检查DB的状态:
<span> 1: </span><span>SELECT</span> DATABASEPROPERTYEX (<span>'DemoSuspect'</span>, <span>'STATUS'</span>) <span>AS</span> <span>'Status'</span>;
<span> 2: </span><span>GO</span>
<span> 3: </span>
<span> 4: </span>Status
<span> 5: </span>------<span>--</span>
<span> 6: </span>SUSPECT
最后修复:
<span> 1: </span><span>ALTER</span> <span>DATABASE</span> DemoSuspect <span>SET</span> EMERGENCY;
<span> 2: </span><span>Go</span>
<span> 3: </span><span>ALTER</span> <span>DATABASE</span> DemoSuspect <span>SET</span> SINGLE_USER;
<span> 4: </span><span>Go</span>
<span> 5: </span><span>DBCC</span> CHECKDB (DemoSuspect, REPAIR_ALLOW_DATA_LOSS) <span>WITH</span> NO_INFOMSGS, ALL_ERRORMSGS;
<span> 6: </span>GO
DemoSuspect是你的DB名称。
还可以参加下面两篇文章:
TechEd Demo: Creating, detaching, re-attaching, and fixing a suspect database
CHECKDB From Every Angle: EMERGENCY mode repair - the very, very last resort
希望这篇Post对您有帮助。
Author: Petter Liu http://wintersun.cnblogs.com