服务器维护,服务器代维,安全设置,漏洞扫描,入侵检测服务

dirtysea 发表于 2013-8-23 23:30:15

SQL 2005 清空日志的方法

<font color="#494949"><font style="background-color:rgb(237, 242, 202)"><font face="simsun">清除日志<br><br>dbcc rebuild_log(数据库名,1,1)<br><br>完成以上步骤后,重新启动SQL SERVER即可。如果数据库能正常启动,数据库就恢复完成;如果无法启动,只能重新创建数据库。=================================================================<br>压缩日志<br><br>1:截断事务日志:<br>BACKUP LOG 数据库名 WITH NO_LOG<br><br>2:清空日志<br>DUMP TRANSACTION 库名 WITH NO_LOG<br><br>再:<br>企业管理器--右键你要压缩的数据库--所有任务--收缩数据库--收缩文件--选择日志文件--在收缩方式里选择收缩至XXM,这里会给出一个允许收缩到的最小M数,直接输入这个数,确定就可以了<br><br><br>3: 删除LOG<br>1:分离数据库 企业管理器->服务器->数据库->右键->分离数据库<br>2:删除LOG文件<br>3:附加数据库 企业管理器->服务器->数据库->右键->附加数据库<br>此法生成新的LOG,大小只有500多K</font></font></font><div><font color="#494949"><font style="background-color:rgb(237, 242, 202)"><font face="simsun"><br></font></font></font></div><div><font color="#494949"><font style="background-color:rgb(237, 242, 202)"><font face="simsun"><br></font></font></font></div><div><font color="#494949"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 宋体; line-height: 25px; "><p style="padding-top: 10px; line-height: 25px; text-indent: 2em; ">第一步 当然还是打开企业管理器了</p><p style="padding-top: 10px; line-height: 25px; text-indent: 0px; "><img src="http://www.cr173.com/up/2012-9/201299992043465608.jpg" alt="" title="点击查看大图" style="padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(227, 227, 227); border-right-color: rgb(227, 227, 227); border-bottom-color: rgb(227, 227, 227); border-left-color: rgb(227, 227, 227); cursor: pointer; "></p><p style="padding-top: 10px; line-height: 25px; text-indent: 2em; ">在分离前最好是先把IIS之类的正在连接数据库的程序关一下,要不然老半天也分离不了。</p><p style="padding-top: 10px; line-height: 25px; text-indent: 0px; "><img src="http://www.cr173.com/up/2012-9/201299992045285883.jpg" alt="" title="点击查看大图" width="600" style="padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(227, 227, 227); border-right-color: rgb(227, 227, 227); border-bottom-color: rgb(227, 227, 227); border-left-color: rgb(227, 227, 227); cursor: pointer; "></p><p style="padding-top: 10px; line-height: 25px; text-indent: 2em; ">也可以选择一下 删除链接 这样可能分离会快一点。</p><p style="padding-top: 10px; line-height: 25px; text-indent: 2em; ">我们再定位到数据库所在的硬盘位置</p><p style="padding-top: 10px; line-height: 25px; text-indent: 0px; "><img src="http://www.cr173.com/up/2012-9/201299992048018569.jpg" alt="" title="点击查看大图" style="padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(227, 227, 227); border-right-color: rgb(227, 227, 227); border-bottom-color: rgb(227, 227, 227); border-left-color: rgb(227, 227, 227); cursor: pointer; "></p><p style="padding-top: 10px; line-height: 25px; text-indent: 2em; ">我们为了保除起见可以把 qq2.mdf备份一份,然后再将 qq2_log.ldf 这个文件重命一下名(200G的文件实在是没地方可以备份)。</p><p style="padding-top: 10px; line-height: 25px; text-indent: 2em; ">然后我们再来附加数据库</p><p style="padding-top: 10px; line-height: 25px; text-indent: 0px; "><img src="http://www.cr173.com/up/2012-9/201299992049249719.jpg" alt="" title="点击查看大图" style="padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(227, 227, 227); border-right-color: rgb(227, 227, 227); border-bottom-color: rgb(227, 227, 227); border-left-color: rgb(227, 227, 227); cursor: pointer; "></p><p style="padding-top: 10px; line-height: 25px; text-indent: 0px; "><img src="http://www.cr173.com/up/2012-9/201299992050173626.jpg" alt="" title="点击查看大图" width="600" style="padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(227, 227, 227); border-right-color: rgb(227, 227, 227); border-bottom-color: rgb(227, 227, 227); border-left-color: rgb(227, 227, 227); cursor: pointer; "></p><p style="padding-top: 10px; line-height: 25px; text-indent: 2em; ">附加到刚刚那个 mdf的文件。注意看下面会提示 .ldf 文件找不到。</p><p style="padding-top: 10px; line-height: 25px; text-indent: 0px; "><img src="http://www.cr173.com/up/2012-9/20129999205120961.jpg" alt="" title="点击查看大图" width="600" style="padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(227, 227, 227); border-right-color: rgb(227, 227, 227); border-bottom-color: rgb(227, 227, 227); border-left-color: rgb(227, 227, 227); cursor: pointer; "></p><p style="padding-top: 10px; line-height: 25px; text-indent: 2em; ">不管他了。选择 .ldf这一分把他给删掉。</p><p style="padding-top: 10px; line-height: 25px; text-indent: 2em; ">然后再确定,哈还原成功了。系统自动生成了一个新的 ldf 文件&nbsp; 504KB</p></span></font></div><div><font color="#494949"><font style="background-color:rgb(237, 242, 202)"><font face="simsun"><br></font></font></font></div><div><font color="#494949"><font style="background-color:rgb(237, 242, 202)"><font face="simsun"><br><br><br></font></font></font><font class="Apple-style-span" color="#494949" face="simsun"><br></font><br></div>
页: [1]
查看完整版本: SQL 2005 清空日志的方法