MySql查表占用空间大小:
SELECT
table_schema AS `Database`, table_name AS `Table`,
CONCAT(ROUND(((data_length + index_length) / 1024 / 1024), 2),' MB') `Size`
FROM information_schema.tables
WHERE table_schema='kyc'
ORDER BY (data_length + index_length) DESC;
查到各表空间容量按大到小排序,如下图:
MySql查数据库占用空间大小:
SELECT
TABLE_SCHEMA, CONCAT(SUM(DATA_LENGTH)/1024/1024,' MB') AS DATA_SIZE, CONCAT(SUM(INDEX_LENGTH)/1024/1024,'MB') AS INDEX_SIZE
, CONCAT(SUM(DATA_LENGTH + INDEX_LENGTH)/1024/1024,' MB') AS TOTAL_SIZE
FROM information_schema.TABLES
GROUP BY TABLE_SCHEMA;
?查到的各数据库大小,如下图: