MySQL数据和索引占用空间查询
查询所有数据库占用磁盘空间大小的SQL语句
SELECT
table_schema, -- 数据库名称
concat( TRUNCATE ( sum( data_length ) / 1024 / 1024, 2 ), 'MB' ) AS data_size, -- 数据占用空间
concat( TRUNCATE ( sum( index_length ) / 1024 / 1024, 2 ), 'MB' ) AS index_size -- 索引占用空间
FROM
information_schema.TABLES
GROUP BY
table_schema
ORDER BY
sum( data_length ) DESC;
查询单个库中所有表磁盘占用大小的SQL语句
SELECT
table_name, -- 表名称
concat( TRUNCATE ( data_length / 1024 / 1024, 2 ), 'MB' ) AS data_size, -- 数据占用空间
concat( TRUNCATE ( index_length / 1024 / 1024, 2 ), 'MB' ) AS index_size -- 索引占用空间
FROM
information_schema.TABLES
WHERE
table_schema = '数据库名称'
ORDER BY
data_length DESC;
點擊查看更多內(nèi)容
為 TA 點贊
評論
評論
共同學(xué)習(xí),寫下你的評論
評論加載中...
作者其他優(yōu)質(zhì)文章
正在加載中
感謝您的支持,我會繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦