国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數(shù)據(jù)庫 > SQL Server > 正文

SQL Server 2005日志文件損壞的處理方法

2024-08-31 00:52:31
字體:
供稿:網(wǎng)友
在實(shí)際的工作和學(xué)習(xí)中,許多人的SQL Server 2005數(shù)據(jù)庫日志文件可能會(huì)發(fā)生損壞,例如硬件故障、計(jì)算機(jī)非正常重啟或關(guān)機(jī)等等。

在SQL Server 2005的日志文件損壞時(shí),你會(huì)發(fā)現(xiàn)以下的情況:

◆1、在SQL Server Management Studio中顯示數(shù)據(jù)庫處于置疑(suspect)狀態(tài)。

◆2、事件日志可能會(huì)出現(xiàn)如下錯(cuò)誤信息:

Could not redo log record (21737:686:9), for transaction ID (0:2334886), on page (1:37527), database 'Test' (database ID 15). Page: LSN = (21735:299:5), type = 2. Log: OpCode = 3, context 19, PRevPageLSN: (21737:615:1). Restore from a backup of the database, or repair the database.

During redoing of a logged Operation in database 'Test', an error occurred at log record ID (76116:286:2). Typically, the specific failure is previously logged as an error in the Windows Event Log service. Restore the database from a full backup, or repair the database.

◆3、無法分離數(shù)據(jù)庫

◆4、用CREATE DATABASE DBName ON ( FILENAME = N'DBFile' ) FOR ATTACH_REBUILD_LOG附加數(shù)據(jù)庫時(shí)出現(xiàn)提示:The log cannot be rebuilt because the database was not cleanly shut down.

詳細(xì)的恢復(fù)方法:

1、停止數(shù)據(jù)庫服務(wù)。

2、將需要恢復(fù)的數(shù)據(jù)庫文件復(fù)制到另外的位置。

3、啟動(dòng)數(shù)據(jù)庫服務(wù)。

4、確認(rèn)要恢復(fù)的數(shù)據(jù)庫文件已經(jīng)成功復(fù)制到另外的位置,然后在SQL Server Management Studio中刪除要恢復(fù)的數(shù)據(jù)庫。

5、新建同名的數(shù)據(jù)庫(數(shù)據(jù)庫文件名也要相同)。

6、停止數(shù)據(jù)庫服務(wù)。

7、用第2步中備份的.mdf文件覆蓋新數(shù)據(jù)庫的同名文件。

8、啟動(dòng)數(shù)據(jù)庫服務(wù)。

9、運(yùn)行alter database dbname set emergency,將數(shù)據(jù)庫設(shè)置為emergency mode

10、運(yùn)行下面的命令就可以恢復(fù)數(shù)據(jù)庫:

use master

declare @databasename varchar(255)

set @databasename='要恢復(fù)的數(shù)據(jù)庫名稱'

exec sp_dboption @databasename, N'single', N'true' --將目標(biāo)數(shù)據(jù)庫置為單用戶狀態(tài)

dbcc checkdb(@databasename,REPAIR_ALLOW_DATA_LOSS)

dbcc checkdb(@databasename,REPAIR_REBUILD)

exec sp_dboption @databasename, N'single', N'false'--將目標(biāo)數(shù)據(jù)庫置為多用戶狀態(tài)

注:這個(gè)方法是通過.mdf文件恢復(fù)數(shù)據(jù)庫,即使大家的log文件丟失也可以進(jìn)行恢復(fù)。


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 潢川县| 绥江县| 蓝山县| 遂川县| 沁水县| 新沂市| 商城县| 阿尔山市| 石渠县| 团风县| 闻喜县| 双城市| 淮阳县| 宁乡县| 偏关县| 渑池县| 湟源县| 阳泉市| 江西省| 罗江县| 团风县| 鄂尔多斯市| 道真| 丽江市| 凤阳县| 容城县| 十堰市| 买车| 孝昌县| 白朗县| 那坡县| 河北省| 信宜市| 板桥市| 清流县| 巫溪县| 淮阳县| 通渭县| 长宁县| 南安市| 司法|