久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術(shù)文章
文章詳情頁

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

瀏覽:3日期:2023-11-05 15:39:17
在實際的工作和學(xué)習(xí)中,許多人的SQL Server 2005數(shù)據(jù)庫日志文件可能會發(fā)生損壞,例如硬件故障、計算機非正常重啟或關(guān)機等等。

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

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

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

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ù)庫時出現(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、啟動數(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、啟動數(shù)據(jù)庫服務(wù)。

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

10、運行下面的命令就可以恢復(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)

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

標(biāo)簽: Sql Server 數(shù)據(jù)庫
主站蜘蛛池模板: 武隆县| 准格尔旗| 克山县| 晴隆县| 诸暨市| 辉县市| 新安县| 永昌县| 眉山市| 云南省| 景德镇市| 新蔡县| 新疆| 定边县| 福建省| 玛纳斯县| 贡觉县| 克什克腾旗| 汾阳市| 郓城县| 太原市| 原阳县| 兴安县| 遵化市| 庆安县| 郓城县| 封丘县| 邵武市| 临澧县| 澄江县| 峡江县| 当阳市| 三门县| 邳州市| 牙克石市| 来宾市| 五大连池市| 孝义市| 湖南省| 五峰| 龙口市|