SqlServer查询表空间占用情况

SELECT
obj.name "表名",
pt.rows  "行数",
SUM(acu.used_pages)*8/1024 "大小(MB)"
FROM sys.objects obj 
JOIN sys.indexes idx on obj.object_id = idx.object_id
JOIN sys.partitions pt on obj.object_id = pt.object_id
JOIN sys.allocation_units acu on acu.container_id = pt.partition_id
WHERE obj.type = 'U' AND idx.index_id IN (0, 1)
GROUP BY obj.name, pt.rows
ORDER BY 3 DESC
—— 完 ——
相关推荐
评论

立 为 非 似

中 谁 昨 此

宵 风 夜 星

。 露 , 辰

文章点击榜

细 无 轻 自

如 边 似 在

愁 丝 梦 飞

。 雨 , 花