萬盛學電腦網

 萬盛學電腦網 >> 數據庫 >> mssql數據庫 >> SQL Server 2008 R2 下如何清理數據庫日志文件

SQL Server 2008 R2 下如何清理數據庫日志文件

 USE [master]

GO
ALTER DATABASE [數據庫名] SET RECOVERY SIMPLE WITH NO_WAIT
GO
ALTER DATABASE [數據庫名] SET RECOVERY SIMPLE
GO
USE [數據庫名]
GO
DBCC SHRINKFILE (N'[數據庫日志文件名稱]' , 0,TRUNCATEONLY)
GO
USE [master]
GO
ALTER DATABASE [數據庫名] SET RECOVERY FULL WITH NO_WAIT
GO
ALTER DATABASE [數據庫名] SET RECOVERY FULL
GO

--查詢指定數據庫的日志文件名稱
USE [數據庫名] 
GO
SELECT name FROM SYS.database_files WHERE type_desc='LOG'
copyright © 萬盛學電腦網 all rights reserved