栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

查看MySQL数据库实例占用的物理空间大小

查看MySQL数据库实例占用的物理空间大小

一. 查询整个mysql占用的空间大小

(单位: M)

SELECt
	round( sum( data_length / 1024 / 1024 ), 2 ) AS size 
FROM
	information_schema.TABLES;

.
.

二. 查询mysql中每个数据库实例占用的空间大小

(单位: M)

SELECt
	table_schema,
	round( sum( data_length / 1024 / 1024 ), 2 ) AS size 
FROM
	information_schema.TABLES 
GROUP BY
	table_schema 
ORDER BY
	size DESC;
三. 查询mysql中某库下没张表占用的空间大小
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 = 'maxwell' 
    -> ORDER BY
    -> table_rows DESC;

+---------+------------+--------+--------------+--------------+
| 数据库  | 表名       | 记录数 | 数据容量(MB) | 索引容量(MB) |
+---------+------------+--------+--------------+--------------+
| maxwell | columns    |  79253 | 5.51         | 3.03         |
| maxwell | tables     |   4482 | 0.31         | 0.18         |
| maxwell | schemas    |   3575 | 45.51        | 0.37         |
| maxwell | databases  |    154 | 0.01         | 0.01         |
| maxwell | positions  |     22 | 0.01         | 0.00         |
| maxwell | heartbeats |     22 | 0.01         | 0.00         |
| maxwell | bootstrap  |      0 | 0.01         | 0.00         |
+---------+------------+--------+--------------+--------------+
7 rows in set (0.06 sec)
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/279938.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号