概述
本日首要先容MySQL查察数据库表容量巨细的几个要领,仅供参考。
1、查察全部数据库容量巨细
- SELECT
- 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)'
- FROM
- information_schema.TABLES
- GROUP BY
- table_schema
- ORDER BY
- sum( data_length ) DESC,
- sum( index_length ) DESC;
2、查察全部数据库各表容量巨细
- 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
- ORDER BY
- data_length DESC,
- index_length DESC;
3、查察指定命据库容量巨细
- SELECT
- 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)'
- FROM
- information_schema.TABLES
- WHERE
- table_schema = 'mysql';
4、查察指定命据库各表容量巨细
- 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 = 'mysql'
- ORDER BY
- data_length DESC,
- index_length DESC;
【编辑保举】 - NoSQL毕竟是什么?相识为什么NoSQL数据库不是传统数据库的敌手
- 详解MySQL索引行使率监控能力,值得保藏
- 关于MySQL数据库整理binlog日记呼吁总结
- 假如你能口试的时辰能答复这些MySQL数据库题目,月薪2万不是题目
- MyCat数据库的基本设置及行使
【责任编辑:庞桂玉 TEL:(010)68476606】
点赞 0 (编辑:河北网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|