USE 数据库名;
GO
-- Truncate the log by changing the database recovery model to SIMPLE.
ALTER DATABASE 数据库名
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (数据库名_Log, 1);
GO
-- Reset the database recovery model.
ALTER DATABASE 数据库名
SET RECOVERY FULL;
GO
GO
-- Truncate the log by changing the database recovery model to SIMPLE.
ALTER DATABASE 数据库名
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (数据库名_Log, 1);
GO
-- Reset the database recovery model.
ALTER DATABASE 数据库名
SET RECOVERY FULL;
GO
本文介绍了一种在SQL Server中通过更改数据库恢复模式来缩小日志文件大小的方法。具体步骤包括:首先将数据库恢复模式更改为简单模式以清空日志;接着压缩已清空的日志文件至指定大小;最后重置数据库恢复模式为完整模式。

840

被折叠的 条评论
为什么被折叠?



