濮阳杆衣贸易有限公司

主頁(yè) > 知識(shí)庫(kù) > 參考sql2012存儲(chǔ)過(guò)程寫(xiě)的統(tǒng)計(jì)所有用戶(hù)表尺寸大小的示例

參考sql2012存儲(chǔ)過(guò)程寫(xiě)的統(tǒng)計(jì)所有用戶(hù)表尺寸大小的示例

熱門(mén)標(biāo)簽:外呼系統(tǒng)的話術(shù) 貴州外呼回?fù)芟到y(tǒng)是什么 云南全自動(dòng)外呼系統(tǒng)公司 衛(wèi)星地圖標(biāo)注距離 智能語(yǔ)音車(chē)載電話機(jī)器人 競(jìng)圣地圖標(biāo)注服務(wù) 陽(yáng)光創(chuàng)信ai外呼獲客系統(tǒng)助力 安陽(yáng)天音防封電銷(xiāo)卡 智能外呼系統(tǒng)需要多少錢(qián)

可以結(jié)合sp_MSforeachdb再遍歷所有用戶(hù)數(shù)據(jù)庫(kù)查看所有表的尺寸大小,注意它的參數(shù)@sql不能超過(guò)nvarchar(2000),這里就不貼出代碼了。
另外還可以定期運(yùn)行并將結(jié)果保存下來(lái),以便觀察數(shù)據(jù)變化趨勢(shì)。

查詢(xún)單個(gè)數(shù)據(jù)庫(kù)的所有用戶(hù)表尺寸大?。?/P>

復(fù)制代碼 代碼如下:

Select @@servername as ServerName,db_name() as DBName ,object_id as ObjectID, schema_name(schema_id) as SchName, name as TableName
    ,Rowcnt as Rows,Columns,Indexes,RowLength
    ,ReservedKb, TableUsedKb
    ,UsedKb-TableUsedKb as IndexUsedKb,ReservedKb-UsedKb as UnusedKb
    ,create_date as CreateDate,modify_date as LastModifiedDate, getutcdate() as TrackingUTCTime
From
(select
    object_id
    ,schema_id
    ,name
    ,(Select max(row_count) from sys.dm_db_partition_stats p with(nolock) where p.object_id=t.object_id and p.index_id 2)  as Rowcnt
    ,(Select Count(1) from dbo.syscolumns with(nolock) where id = t.object_id) as Columns
    ,(Select Count(distinct index_id) from sys.dm_db_partition_stats p with(nolock) where p.object_id=t.object_id) as Indexes
    ,(SELECT SUM(length) FROM dbo.syscolumns with(nolock) WHERE id = t.object_id) as RowLength
    ,IsNull((Select SUM(reserved_page_count) from sys.dm_db_partition_stats p with(nolock) where p.object_id=t.object_id),0)*8
        + IsNull((Select sum(reserved_page_count)
                FROM sys.dm_db_partition_stats p2 with(nolock)
                inner join sys.internal_tables it with(nolock) on p2.object_id = it.object_id
                WHERE it.parent_id = t.object_id
                        AND it.internal_type IN (202,204,207,211,212,213,214,215,216,221,222,236)),0)* 8 as ReservedKb
    ,IsNull((Select SUM(in_row_data_page_count + lob_used_page_count + row_overflow_used_page_count)
                 from sys.dm_db_partition_stats p with(nolock) where p.object_id=t.object_id and p.index_id 2),0)* 8 as TableUsedKb
    ,IsNull((Select SUM(used_page_count) from sys.dm_db_partition_stats p with(nolock) where p.object_id=t.object_id),0)*8
        + IsNull((Select sum(used_page_count)
                FROM sys.dm_db_partition_stats p2 with(nolock)
                inner join sys.internal_tables it with(nolock) on p2.object_id = it.object_id
                WHERE it.parent_id = t.object_id
                        AND it.internal_type IN (202,204,207,211,212,213,214,215,216,221,222,236)),0)* 8 as UsedKb
    ,create_date
    ,modify_date
from sys.tables t with(nolock)
where Type='U'
) A
order by ReservedKb desc

標(biāo)簽:湘潭 河源 周口 營(yíng)口 寧夏 鄂爾多斯 預(yù)約服務(wù) 欽州

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《參考sql2012存儲(chǔ)過(guò)程寫(xiě)的統(tǒng)計(jì)所有用戶(hù)表尺寸大小的示例》,本文關(guān)鍵詞  參考,sql2012,存儲(chǔ),過(guò)程,寫(xiě)的,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《參考sql2012存儲(chǔ)過(guò)程寫(xiě)的統(tǒng)計(jì)所有用戶(hù)表尺寸大小的示例》相關(guān)的同類(lèi)信息!
  • 本頁(yè)收集關(guān)于參考sql2012存儲(chǔ)過(guò)程寫(xiě)的統(tǒng)計(jì)所有用戶(hù)表尺寸大小的示例的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    平武县| 马边| 尚义县| 内乡县| 保山市| 宿松县| 龙岩市| 旬邑县| 自贡市| 河池市| 平潭县| 苍山县| 承德市| 九寨沟县| 湘潭市| 尚志市| 全椒县| 易门县| 哈密市| 土默特右旗| 贵南县| 长阳| 福贡县| 白沙| 岚皋县| 土默特右旗| 水富县| 乡宁县| 平遥县| 梅河口市| 磐石市| 志丹县| 大埔县| 潜江市| 延吉市| 永年县| 汕尾市| 临漳县| 青冈县| 茶陵县| 公安县|