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;
趙小胖個人博客:https://zc.happyloves.cn:4443/wordpress/
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/45098.html
標籤:Java
