SQL-收缩数据库日志文件

问题描述:

我正在尝试缩小数据库日志文件.我尝试运行:

I am trying to shrink my database log file. I have tried to run:

USE databasename 
BACKUP log databasename
WITH truncate_only 
DBCC shrinkfile (databasename_log, 1)

我收到错误消息:

155消息,第15层,状态1,第3行 无法识别"truncate_only" BACKUP选项.

Msg 155, Level 15, State 1, Line 3 'truncate_only' is not a recognized BACKUP option.

我想念什么吗?

SQL Server 2008不再允许NO_LOG/TRUNCATE_ONLY选项.

SQL Server 2008 no longer allows the NO_LOG / TRUNCATE_ONLY options.

要截断事务日志,您必须备份(真实)或将数据库的恢复模型切换为简单".后者可能是您真正想要的.除非您要进行常规的事务日志备份以使其能够恢复到一天中的某个时间点,否则不需要完全恢复.

To truncate your transaction log, you either have to back it up (for real) or switch the database's Recovery Model to Simple. The latter is probably what you really want here. You don't need Full recovery unless you are making regular transaction log backups to be able to restore to some point mid-day.