SQLServer (2005/2008) 日志清理方法

 

--数据库日志名称查询

USE DBNAME

GO

SELECT file_id, name,* FROM sys.database_files;

GO
-------------------------------------------------------------------------------------------------------

 

--SQL SERVER 2005 清理方法

USE [master]

BACKUP LOG DBNAME WITH no_log

USE APP

DBCC SHRINKFILE ('DBNAME_log',100)

-------------------------------------------------------------------------------------------------------

--SQL SERVER 2008 清理方法

USE [master];
GO
ALTER DATABASE DBNAME SET RECOVERY SIMPLE WITH NO_WAIT;
GO
ALTER DATABASE DBNAME SET RECOVERY SIMPLE;--简单模式

GO
USE [DBNAME];
GO
DBCC SHRINKFILE (N'DBNAME_Log' , 11, TRUNCATEONLY);
GO

 

USE [master];
GO
ALTER DATABASE DBNAME SET RECOVERY FULL WITH NO_WAIT;
GO
ALTER DATABASE DBNAME SET RECOVERY FULL; --还原为完全模式
GO

-------------------------------------------------------------------------------------------------------

 

posted @ 2018-02-23 14:50  ypq  阅读(3461)  评论(0编辑  收藏  举报