SQL Server中 ldf 檔案過大的解決方法

2021-06-09 06:43:55 字數 446 閱讀 5605

sql

server中經常遇到事務日誌變大的情況,除了將資料庫設定為「自動收縮」外,還可以使用下面的sql命令進行快速清除資料庫中的事務日誌,命令如下: 

第一步:清空日誌:

dump transaction dataname with no_log

第二步:截斷事務日誌

backup log dataname with no_log

第三步:收縮資料庫itpub個人空間

dbcc shrinkdatabase(databasenames)

需要說明幾點:

上面的sql命令需要按照順序執行;

執行上面的命令通常比直接使用右鍵選單中的「收縮」命令要快很多。

注:適用於sql2000-2005,sql2008不適用!

sql server處理 壓縮LDF檔案

ldf mdf檔案太大了,要壓縮處理 select name,recovery model desc from sys.databases 檢視是什麼模式 這裡的dnname log 如果不知道在sys.database files裡是什麼名字的話,可以用以下注釋的語句進行查詢 use dnname...

sqlserver離線時ldf檔案丟失重建

設定離線 alter database test2 set offline with no wait 刪除日誌檔案,找到目錄刪除ldf檔案 資料庫重新上線 alter database test2 set online with no wait 重建日誌 alter database test2 r...

mdf檔案和ldf檔案是什麼?

在微軟的sql server 2000 資料庫有三種型別的檔案 型別縮寫 中文意思 mdfprimary data file 主要資料檔案 ndfsecondary data files 次要資料檔案 ldflog data files 事務日誌檔案 主要資料檔案包含資料庫的啟動資訊,並指向資料庫中...