MySql查看表空间占用并优化碎片


SELECT
	table_name AS '表名',
	table_schema AS '数据库',
	SUM(table_rows) AS '记录数',
	SUM(TRUNCATE(data_length / 1024 / 1024, 2 )) AS '数据容量(MB)',
	SUM(TRUNCATE(index_length / 1024 / 1024, 2 )) AS '索引容量(MB)',
	SUM(TRUNCATE(DATA_FREE / 1024 / 1024, 2 )) AS '碎片占用(MB)' 
FROM information_schema.TABLES 
GROUP BY table_schema, table_name
ORDER BY SUM(data_length) DESC, SUM(index_length) DESC;


OPTIMIZE TABLE tk_new_user_card;
或
ALTER TABLE tk_new_user_card ENGINE='InnoDB';

(152)
打赏 支付红包 支付红包 微信打赏 微信打赏
上一篇 2023-04-06 18:42:08
下一篇 2023-04-19 15:11:27

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信