1. 程式人生 > >SQLServer (2005/2008) 日誌清理方法

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

sys del ase log alter lec 數據庫日誌 gpo rec

--數據庫日誌名稱查詢

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

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

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