{"id":593,"date":"2018-03-07T10:15:16","date_gmt":"2018-03-07T02:15:16","guid":{"rendered":"https:\/\/blog.freesilo.com\/?p=593"},"modified":"2018-03-07T10:15:16","modified_gmt":"2018-03-07T02:15:16","slug":"sql-server-2008-%e6%94%b6%e7%bc%a9%e6%97%a5%e5%bf%97%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/freesilo.com\/?p=593","title":{"rendered":"SQL Server 2008 \u6536\u7f29\u65e5\u5fd7\u65b9\u6cd5"},"content":{"rendered":"<p>\u4e3a\u4e86\u5b89\u5168\u8d77\u89c1\uff0cSQL Server 2008 \u53ca\u4ee5\u540e\u7248\u672c\u7684 SQL Server \u5df2\u7ecf\u5e9f\u5f03\u4e86\u65e5\u5fd7\u201c\u66b4\u529b\u201d\u6e05\u9664\u547d\u4ee4\uff1a<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\nBACKUP LOG WITH TRUNCATE_ONLY\r\n<\/pre>\n<p>\u4f46\u5728SQL Server 2008 \u53ca\u4ee5\u540e\u7248\u672c\u4e2d\u5141\u8bb8\u5907\u4efd\u65e5\u5fd7\u540e\u6536\u7f29\u65e5\u5fd7\uff0c\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\nUSE AdventureWorks\r\nBACKUP LOG AdventureWorks TO DISK='F:\\MSSQL_Backup\\AdventureWorks.trn'\r\nDBCC SHRINKFILE (AdventureWorks_Log, 1024)\r\n<\/pre>\n<p>\u5373\uff0c\u9996\u5148\u4f7f\u7528 BACKUP LOG \u547d\u4ee4\u5907\u4efd\u65e5\u5fd7\uff0c\u7136\u540e\u4f7f\u7528 DBCC SHRINKFILE \u547d\u4ee4\u6536\u7f29\u6587\u4ef6\uff0c\u5176\u4e2d\u7684\u6587\u4ef6\u540d\uff08AdventureWorks_Log\uff09\u4e3a\u65e5\u5fd7\u6587\u4ef6\u7684\u903b\u8f91\u6587\u4ef6\u540d\uff0c\u540e\u9762\u7684\u6570\u5b57\u4e3a\u4fdd\u7559\u7684\u65e5\u5fd7\u6587\u4ef6\u5927\u5c0f\uff0c\u5355\u4f4d\u4e3a MB\u3002<\/p>\n<p>\u53e6\u5916\uff0c\u4f7f\u7528\u6b64\u65b9\u6cd5\u4ecd\u7136\u53ef\u4ee5\u505a\u5230\u201c\u66b4\u529b\u201d\u6e05\u9664\u7684\u6548\u679c\uff0c\u5c31\u662f\u5728\u5907\u4efd\u65e5\u5fd7\u65f6\uff0c\u5c06\u5907\u4efd\u6587\u4ef6\u540d\u4fee\u6539\u4e3a &#8216;nul&#8217;\uff0c\u5373\uff1a<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\nBACKUP LOG AdventureWorks TO DISK='nul'\r\n<\/pre>\n<p>\u6b64\u65f6\uff0c\u5c06\u4e0d\u4f1a\u521b\u5efa\u65e5\u5fd7\u5907\u4efd\u6587\u4ef6\uff0c\u4f46\u4ecd\u7136\u53ef\u4ee5\u6536\u7f29\u65e5\u5fd7\u3002<br \/>\n\u4f46\u662f\u6b64\u65b9\u6cd5\u5c06\u4e22\u5931\u6570\u636e\u5e93\u65e5\u5fd7\uff0c\u5bf9\u6570\u636e\u5e93\u662f\u5371\u9669\u7684\uff0c\u9664\u975e\u4f60\u7684\u6570\u636e\u5e93\u4e0d\u91cd\u8981\uff0c\u5426\u5219\uff0c\u4e0d\u8981\u7528\uff01<\/p>\n<p>\u6b64\u5916\uff0c\u5e38\u89c4\u7684\u529e\u6cd5\u662f\u4fee\u6539\u6570\u636e\u5e93\u7684\u6062\u590d\u6a21\u5f0f\u4e3a\u7b80\u5355\u6a21\u5f0f\uff0c\u7136\u540e\u6536\u7f29\u65e5\u5fd7\uff0c\u518d\u5c06\u6062\u590d\u6a21\u5f0f\u6539\u4e3a\u5b8c\u6574\u6a21\u5f0f\uff0c\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\n---------------------------------\u6570\u636e\u5e93\u65e5\u5fd7\u6587\u4ef6\u6536\u7f29--------------\r\nUSE &#x5B;master]\r\n--\u7b80\u5355\u6a21\u5f0f\r\nALTER DATABASE DBName SET RECOVERY SIMPLE WITH NO_WAIT\r\nGO\r\nUSE DBName \r\nGO\r\n--\u6267\u884c\u6536\u7f29\u547d\u4ee4\uff0c\u6536\u7f29\u52305MB\r\nDBCC SHRINKFILE (N'DBName_log' , 5, TRUNCATEONLY)\r\nGO\r\nUSE &#x5B;master]\r\nGO\r\n--\u8fd8\u539f\u4e3a\u5b8c\u5168\u6a21\u5f0f\r\nALTER DATABASE MemberDB SET RECOVERY FULL WITH NO_WAIT\r\nGO\r\n<\/pre>\n<p>\u4f46\u662f\u5728\u7b80\u5355\u6a21\u5f0f\u4e0b\uff0c\u6570\u636e\u5e93\u7684\u5b89\u5168\u6027\u964d\u4f4e\uff0c\u4e0d\u5efa\u8bae\u4f7f\u7528\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e3a\u4e86\u5b89\u5168\u8d77\u89c1\uff0cSQL Server 2008 \u53ca\u4ee5\u540e\u7248\u672c\u7684 SQL Server&#8230;<br \/><a class=\"read-more-button\" href=\"https:\/\/freesilo.com\/?p=593\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-593","post","type-post","status-publish","format-standard","hentry","category-sql-server"],"_links":{"self":[{"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/posts\/593","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/freesilo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=593"}],"version-history":[{"count":1,"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/posts\/593\/revisions"}],"predecessor-version":[{"id":594,"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/posts\/593\/revisions\/594"}],"wp:attachment":[{"href":"https:\/\/freesilo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=593"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/freesilo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=593"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/freesilo.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=593"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}