如何查看資料檔案或者Log檔案是否增長過?

來源:互聯網
上載者:User

在論壇看到一個文章,說資料庫變慢了一段時間,發現這段時間資料庫檔案的最後修改時間跟變慢的世界一致,想知道這段時間是否檔案確實增長了。

其實SQL Server提供了資料增長的Event,而且Default Trace裡面就記錄了。

下面我們做個測試,我建立了一個新的資料庫,建立表然後插入資料:

createtabletest(testvarchar(100))

go

insertintotestvalues (replicate('a',100))

go 100000

 

現在查詢Default Trace:

declare @TraceFileasvarchar(max)

select@TraceFile=path fromsys.traces

 

selectDatabaseName,FileName,StartTime

from::fn_trace_gettable(@TraceFile,default)--替換你自己的Trace檔案地址

whereEventClass= 92 or EventClass= 93 andStartTime> '2013-06-2813:09:49.767'

 

關於Event 92和93的解釋: 

 

select*fromsys.trace_eventswheretrace_event_id= 92  or trace_event_id= 93

650) this.width=650;" title="1.png" style="float:left;" src="http://www.bkjia.com/uploads/allimg/131228/22232330O-0.png" />

 

結果如下:

 

650) this.width=650;" title="2.png" style="float:left;" src="http://www.bkjia.com/uploads/allimg/131228/2223235305-1.png" />

 

 

 

 

 

 

 

 

 

 

 

 

 

 

可以看到資料庫增長的記錄。

本文出自 “關注SQL Server技術” 部落格,請務必保留此出處http://lzf328.blog.51cto.com/1196996/1231688

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.