使用查詢分析器 清理日誌,使記錄檔縮小

來源:互聯網
上載者:User
方法1、   
  在當前資料庫下     select   fileid,groupid,name   from   sysfiles   where   groupid=0     ----------------------------------------------------------     得到以下結果     fileid           groupid                     name         2                     0                                 test_log      以上結果,fileid為記錄檔ID,name為test_log   

--在查詢分析器,選中所要清理日誌的資料庫,執行如下SQL
backup log 資料庫名 with no_log
DBCC SHRINKFILE (記錄檔名或記錄檔ID,要縮小的目標大小)
如:
backup log test with no_log
dbcc shrinkfile (2,2)
or
backup log test with no_log  

   DBCC  SHRINKFILE   ('test_log',10)   
  如果以後,不想要它變大,在資料庫上點右鍵->屬性->選項->故障恢複     模型   選擇   簡單模型就可以了!     或用SQL語句     alter   database   資料庫名   set   recovery   simple         方法2、     SQL   SERVER企業管理器-》SQL   SERVER組-》伺服器-》資料庫-》選中資料庫實體-》右鍵-》所有任務-》分離資料庫,     然後到資料庫所在實體路徑下刪除.ldf檔案,再資料庫右鍵-》所有任務-》附加資料庫,即可,會重建記錄檔。   

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.