清除,收缩或截断数据库日志

DBCC SHRINKFILE (@LogicalFileName, @NewSize)

再是
BACKUP LOG dbname WITH TRUNCATE_ONLY



或者,先设置数据库为简单恢复模式,再收缩文件,然后再设置数据库为完整恢复模式。(要是数据库原来就是简单恢复模式,就直接收缩文件即可)
e.g:

USE AdventureWorks;
GO
-- Truncate the log by changing the database recovery model to SIMPLE.
ALTER DATABASE AdventureWorks
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (AdventureWorks_Log, 1);
GO
-- Reset the database recovery model.
ALTER DATABASE AdventureWorks
SET RECOVERY FULL;
GO
要是截断日志,可以这样:
BACKUP LOG dbname WITH NO_LOG
Dbcc Shrinkdatabase('dbname')

posted @ 2010-01-27 09:01  rock.dean  阅读(340)  评论(0编辑  收藏  举报