SQL Server事务日志可能会被填满,这会阻止之后的数据库操作,包括UPDATE, DELETE, INSERT 和CHECKPOINT。 事务日志填满会导致1105错误: Can't allocate space for object syslogs in database dbname because the logsegment is full。 If you ran out of space in syslogs, dump the transaction log。 Otherwise use ALTER DATABASE or sp_extendsegment to increase the size of the segment。
GO ALTER DATABASE DB_NAME SET RECOVERY SIMPLE b.如果你的恢复模式是全部,你一定要配置日志字段收缩:
USE MASTER
GO sp_dboption 'databasename','trunc. log on chkpt.',true sp_dboption 'databasename','autoshrink',true c.通过每日备份将日志收缩: BACKUP DATABASE DATABASE_NAME TO BACKUP_DEVICES BACKUP LOG DATABASE_NAME TO LOG_DEVICES OR BACKUP LOG DATABASE_NAME with truncate_only
**检查日志的容量:DBCC SQLPERF (LOGSPACE) 这时日志并没有收缩!
d.每天在备份数据库完成之后,重新启动MS SQLSERVER SERVICE. USE DATABASE_NAME go DBCC SHRINKFILE(2,truncateonly)
**检查日志的容量:DBCC SQLPERF (LOGSPACE) 这时日志已经收缩!
e.手动快速收缩日志: / *run below script,you will shrink you database log files immediately, in my experience,you need to run the script for 3 or 4 minutes before stopping it manually */ use databasename dbcc shrinkfile(2,notruncate) dbcc shrinkfile(2,truncateonly) create table t1(char1 char(4000)) go declare @i int select @i=0 while(1=1) begin while(@i<100) begin INSERT INTO T1 VALUES ('A') SELECT @I=@I+1 END TRUNCATE table T1 BACKUP LOG youdatabasename with truncate_only end GO