如何使用sql語句使你的數據庫減肥,下面以網狐6603數據庫減肥腳本舉例!

原文轉自:http://www.zccode.com/forum.php?mod=viewthread&tid=637&extra=page%3D1php

 

網狐6603 專用數據庫減肥特效腳本(18G變成300M)以下:sql

將腳本語句複製到sql server 新建查詢中,執行便可,能夠清楚冗餘的日誌數據庫

 

/*
* 數據庫超級減肥, 18G可變成300M.日誌

*/ code

-- Truncate the log by changing the database recovery model to SIMPLE.
use qptreasuredb
ALTER DATABASE qptreasuredb
SET RECOVERY SIMPLE
GO
-- Shrink the truncated log file to 1 MB. 收縮日誌文件大小(單位是M)
DBCC SHRINKFILE (qptreasuredb_log, 1)
GO
-- Reset the database recovery model.
ALTER DATABASE qptreasuredb
SET RECOVERY FULLserver

use qprecorddb
ALTER DATABASE qprecorddb
SET RECOVERY SIMPLE
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (qprecorddb_log, 1)
GO
-- Reset the database recovery model.
ALTER DATABASE qprecorddb
SET RECOVERY FULLthread

use qpaccountsdb
ALTER DATABASE qpaccountsdb
SET RECOVERY SIMPLE
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (qpaccountsdb_log, 1)
GO
-- Reset the database recovery model.
ALTER DATABASE qpaccountsdb
SET RECOVERY FULL
GOfile


use QPEducateDB
ALTER DATABASE QPEducateDB
SET RECOVERY SIMPLE
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (QPEducateDB_log, 1)
GO
-- Reset the database recovery model.
ALTER DATABASE QPEducateDB
SET RECOVERY FULL
go
select * from sys.database_files --查找數據庫log文件邏輯名select

相關文章
相關標籤/搜索