查詢mysql佔用多少空間
阿新 • • 發佈:2018-11-01
MYSQL 查詢佔用多大磁碟空間
select concat(truncate(sum(data_length)/1024/1024,2),’MB’) as data_size, concat(truncate(sum(max_data_length)/1024/1024,2),’MB’) as max_data_size, concat(truncate(sum(data_free)/1024/1024,2),’MB’) as data_free, concat(truncate(sum(index_length)/1024/1024,2),’MB’) as index_size from information_schema.tables where TABLE_NAME = ‘table_name’;
table_name是表名
##查詢mysql佔用多少空間
use information_schema;
SELECT TABLE_NAME,DATA_LENGTH+INDEX_LENGTH,TABLE_ROWS,concat(round((DATA_LENGTH+INDEX_LENGTH)/1024/1024,2), 'MB')
as data FROM TABLES WHERE TABLE_SCHEMA='table_shema';
table_shema是庫名