日志文件满而造成SQL数据库无法写入文件时,可用两种方法:
一种方法:清空日志。
1.打开查询分析器,输入命令
DUMPTRANSACTION数据库名WITHNO_LOG
2.再打开企业管理器–右键你要压缩的数据库–所有任务–收缩数据库–收缩文件–选择日志文件–在收缩方式里选择收缩至XXM,这里会给出一个允许收缩到的最小M数,直接输入这个数,确定就可以了。
另一种方法有一定的风险性,因为SQLSERVER的日志文件不是即时写入数据库主文件的,如处理不当,会造成数据的损失。
1:删除LOG
分离数据库企业管理器->服务器->数据库->右键->分离数据库
2:删除LOG文件
附加数据库企业管理器->服务器->数据库->右键->附加数据库
此法生成新的LOG,大小只有500多K。
注意:建议使用第一种方法。
如果以后,不想要它变大。
SQL2000下使用:
在数据库上点右键->属性->选项->故障恢复-模型-选择-简单模型。
或用SQL语句:
alterdatabase数据库名setrecoverysimple
另外,Truncatelogoncheckpoint(此选项用于SQL7.0,SQL2000中即故障恢复模型选择为简单模型)当执行CHECKPOINT命令时如果事务日志文件超过其大小的70%则将其内容清除在开发数据库时时常将此选项设置为TrueAutoshrink定期对数据库进行检查当数据库文件或日志文件的未用空间超过其大小的25%时,系统将会自动缩减文件使其未用空间等于25%当文件大小没有超过其建立时的初始大小时不会缩减文件缩减后的文件也必须大于或等于其初始大小对事务日志文件的缩减只有在对其作备份时或将Truncatelogoncheckpoint选项设为True时才能进行。
注意:一般立成建立的数据库默认属性已设好,但碰到意外情况使数据库属性被更改,请用户清空日志后,检查数据库的以上属性,以防事务日志再次充满。
最新评论
Hey! I could have sworn I've been to this blog before but after checking through some of the post I realized it's new to me. Anyways, I'm definitely delighted I found it and I'll be book-marking and checking back often!
Heya i am for the primary time here. I came across this board and I to find It really helpful & it helped me out much. I'm hoping to give something back and help others like you helped me.
Pretty element of content. I simply stumbled upon your website and in accession capital to claim that I acquire in fact enjoyed account your weblog posts. Any way I’ll be subscribing for your augment and even I success you access persistently rapidly.
Would love to perpetually get updated outstanding weblog! .
Some really nice stuff on this internet site, I like it.
Can I simply say what a reduction to find somebody who actually knows what theyre talking about on the internet. You positively know find out how to carry an issue to mild and make it important. Extra individuals have to read this and understand this facet of the story. I cant believe youre not more fashionable because you positively have the gift.
I like this post, enjoyed this one appreciate it for posting.
Definitely, what a splendid blog and enlightening posts, I surely will bookmark your site.Best Regards!