如何使用sql语句使你的数据库减肥,下面以网狐6603数据库减肥脚本举例!

时间:2024-03-07 13:34:09

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

 

网狐6603 专用数据库减肥特效脚本(18G变成300M)如下:

将脚本语句复制到sql server 新建查询中,执行即可,可以清楚冗余的日志

 

/*
* 数据库超级减肥, 18G可变成300M.

*/

-- 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 FULL

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 FULL

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
GO


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文件逻辑名