若要允许 DBCC SHRINKFILE 命令收缩文件,首先需要通过将数据库恢复模式设置为 SIMPLE 来截断该文件。

示例,收缩数据库abce的事务日志

USE abce;
GO
-- Truncate the log by changing the database recovery model to SIMPLE.
ALTER DATABASE abce
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (abce_Log, 1);
GO
-- Reset the database recovery model.
ALTER DATABASE abce
SET RECOVERY FULL;
GO

  

05-07 15:33