sql server收縮資料庫日誌

2021-10-07 17:01:25 字數 455 閱讀 8026

alter

database testdbname set recovery ******

--將「恢復模式」設定為「簡單」

gouse testdbname

godbcc shrinkfile (n'testdbname_log',1

, truncateonly)

--收縮日誌檔案大小到1m

gouse testdbname

goalter

database testdbname set recovery full

with no_wait ----將「恢復模式」設定為「完整」

goalter

database testdbname set recovery full

go

將testdbname替換為需要收縮日誌的資料庫名稱執行sql即可快速收縮資料庫。

SQLServer收縮資料庫

以下語句用於設定資料庫定時自動收縮資料庫 use master gosp dboption testdb,autoshrink true gouse testdb gocheckpoint go 清空日誌語句 dump transaction testdb with no log 截斷事務日誌 ba...

收縮sql server資料庫日誌

專案中,可能資料庫 sql server資料庫 日誌太多,佔了很多磁碟空間,可以通過收縮資料庫日誌,減少日誌檔案大小。下面以northwind資料庫為例 1.把資料庫的恢復模式設定為 簡單模式 選擇northwind資料庫 右鍵 屬性,在彈出的資料庫屬性視窗中,選擇 選項 設定恢復模式為 簡單 點選...

SQL SERVER 收縮資料庫的命令

1.清空日誌 dump transaction 庫名 with no log 2.截斷事務日誌 backup log 資料庫名 with no log 3.收縮資料庫檔案 如果不壓縮,資料庫的檔案不會減小 企業管理器 右鍵你要壓縮的資料庫 所有任務 收縮資料庫 收縮檔案 選擇日誌檔案 在收縮方式裡選...