数据库大小及表数据量

--查数据库大小M
SELECT database_id AS DataBaseId,DB_NAME(database_id) AS DataBaseName,CAST(SUM(SIZE)*8.0/1024/1024 AS DECIMAL(9, 4)) AS [Size(GB)]
FROM sys.master_files
GROUP BY database_id

--也可以使用convert(bigint,size/128) as [size MB] 计算(单个page 8K)

--查各表记录数
select a.name as tab_name,max(b.rows) as row_num  
from sysobjects a,sysindexes b
where a.id=b.id and a.xtype='u'
group by a.name
order by max(b.rows) desc

posted @   大漠老兵  阅读(501)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示