Home > Database > Mysql Tutorial > MSSQL 2005/2008日志文件瘦身

MSSQL 2005/2008日志文件瘦身

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:21:39
Original
986 people have browsed it

在SQL2000/2005中可以快速压缩日志log文件,对于SQL2008以上命令不能运行,SQL2008说明:BACKUP LOG WITH NO_LOG 和 WITH TRUNCAT

在SQL2000/2005中可以快速压缩日志log文件,,通过SQL:

--myDbName是需要瘦身的数据库名

backup log myDbName with no_log;
backup log myDbName with truncate_only;
dbcc SHRINKDATABASE(myDbName);

对于SQL2008以上命令不能运行,SQL2008说明:BACKUP LOG WITH NO_LOG 和 WITH TRUNCATE_ONLY 选项已废止。使用完整恢复模式或大容量日志恢复模式时,如果必须删除数据库中的日志备份链,请切换至简单恢复模式。有关详细信息,请参阅有关从完整恢复模式或大容量日志恢复模式切换的注意事项。

操作语句如下:

USE [master]
GO
ALTER DATABASE MyDbName SET RECOVERY SIMPLE WITH NO_WAIT
GO
ALTER DATABASE MyDbName SET RECOVERY SIMPLE  --简单模式
GO
USE MyDbName
GO
DBCC SHRINKFILE (N'MyDbName_LogFileName' , 1, TRUNCATEONLY)
GO
USE [master]
GO
ALTER DATABASE MyDbName SET RECOVERY FULL WITH NO_WAIT
GO
ALTER DATABASE MyDbName SET RECOVERY FULL  --还原为完全模式
GO


其中DBCC SHRINKFILE (N'MyDbName_LogFileName' , 1, TRUNCATEONLY)中的

第一个参数可以用以下语句获取:select name from sys.database_files where type=1

第二个参数代表最终日志文件大小,1即1M.

linux

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template