查询mysql表空间占用大小

SELECT
	table_schema AS '数据库',
	table_name AS '表名',
	table_rows AS '记录数',
	TRUNCATE ( data_length / 1024 / 1024, 2 ) AS '数据容量(MB)',
	TRUNCATE ( index_length / 1024 / 1024, 2 ) AS '索引容量(MB)' 
FROM
	information_schema.TABLES 
WHERE
	table_schema = 'your db name' 
ORDER BY
	table_rows DESC,
	index_length DESC;

猜你喜欢

转载自blog.csdn.net/lixu1119545729/article/details/127224114