SQL Server 2008 R2:快速清除日志文件的方法

本例,快速清理“students”数据库的日志,清理后日志文件不足1M。

USE [master]  
GO  
ALTER DATABASE students SET RECOVERY SIMPLE WITH NO_WAIT  
GO  
ALTER DATABASE students SET RECOVERY SIMPLE  
GO  
USE students  
GO
--此处需要注意,并非所有数据库的日志文件名都是“数据库名_log”  
DBCC SHRINKFILE (N'students_log' , 0,TRUNCATEONLY)  
GO  
USE [master]  
GO  
ALTER DATABASE students SET RECOVERY FULL WITH NO_WAIT  
GO  
ALTER DATABASE students SET RECOVERY FULL  
GO  
  
--查询指定数据库的日志文件名称  
USE students   
GO  
SELECT name FROM SYS.database_files WHERE type_desc='LOG' 
posted @ 2019-04-01 13:59  KIMI-father  阅读(2610)  评论(0编辑  收藏  举报