檢視錶大小

刚好遇见Mysql發表於2024-03-21

USE ncdb;
SELECT
OBJECT_NAME(object_id) AS TableName,
SUM(reserved_page_count) * 8 AS TotalSizeKB,
SUM(CAST(CASE WHEN index_id < 2 THEN in_row_data_page_count + lob_used_page_count + row_overflow_used_page_count ELSE 0 END AS BIGINT)) * 8 AS DataSizeKB,
SUM(CAST(CASE WHEN index_id < 2 THEN used_page_count ELSE 0 END AS BIGINT)) * 8 AS IndexSizeKB
FROM
sys.dm_db_partition_stats
GROUP BY
object_id
order by TotalSizeKB desc

相關文章