修復資料庫置疑

2021-09-01 21:04:57 字數 1066 閱讀 8947

---確定硬碟沒有壞道,無問題情況下

---1.停止sql 服務,獲取資料庫路徑,刪掉日誌檔案

use master

goselect name,reverse(substring(reverse(filename),charindex('\',reverse(filename)),1000))  from sysdatabases

---2.啟動sql 服務

use master

gosp_configure 'allow update',1

reconfigure with override

goupdate sysdatabases set status = 32768 where name = 'test'

go---重建資料庫日誌檔案

dbcc rebuild_log('test','f:\test\data\test_log.ldf')  --最好在原路徑上面,資料夾一定要原來就存在,不然會提示錯誤.

gouse master

update sysdatabases set status = 8 where name = 'test'

gosp_configure'allow updates',0

reconfigure with override

go---這個時候.資料庫應該已經不是置疑的.並且可以使用了.只是有部分損壞

---3.修復資料庫

use master

declare @databasename varchar(255)

set @databasename='test'

exec sp_dboption @databasename, n'single', n'true'

dbcc checkdb(@databasename,repair_allow_data_loss)

dbcc checkdb(@databasename,repair_rebuild)

exec sp_dboption @databasename, n'single', n'false'

---4.最後修復完.再dbcc checkdb一次

SQL資料庫修復 資料庫置疑修復

sql資料庫修復的三大核心技術 1 磁碟陣列分析重組技術 2 資料庫恢復與修復技術 3 scsi盤物理故障開盤技術。至今已經成功恢復數百台伺服器的sql資料庫,使用者覆蓋全國。導致sql資料庫丟失的原因 1 各種原因 誤刪除 誤格式化 斷電等造成的ms sql server資料庫檔案破壞。2 ms ...

修復資料庫

如果備份的資料庫有2個檔案,分別是.ldf 和 mdf,開啟企業管理器,在例項上右擊 所有任務 附加資料庫,然後選擇那個.mdf檔案,就可以了。或者在查詢分析器中輸入 sp attach db 資料庫名稱 路徑 檔名.ldf 路徑 檔名.mdf sql server資料庫備份有兩種方式,一種是使用b...

SQL SERVER 2005 資料庫置疑修復

alter database 置疑資料庫 set emergency go alter database 置疑資料庫 set single user with rollback immediate go use master go alter database 置疑資料庫 rebuild log o...