mysql查看数据库大小以及使用情况?

一、用SQL命令查看Mysql数据库大小

要想知道每个数据库的大小的话,步骤如下:

1、进入information_schema 数据库(存放了其他的数据库的信息)

use information_schema;

2、查询所有数据的大小

select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables;

3、查看指定数据库的大小

比如查看数据库home的大小

select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='home';

4、查看指定数据库的某个表的大小

比如查看数据库home中 members 表的大小

select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='home' and table_name='members';

查看MySql数据空间使用情况:

information_schema是MySQL的系统数据库,information_schema里的tables表存放了整个数据库各个表的使用情况。

可以使用sql来统计出数据库的空间使用情况,相关字段:

table_schema:数据库名

table_name:表名

table_rows:记录数

data_length:数据大小

index_length:索引大小

二、使用空间

1、统计表使用空间

select concat(round(sum(data_length/1024/1024),2),'mb') as data from tables where table_schema='mydb' and table_name='mytable';

| data |

| 0.02mb |

1 row in set (0.00 sec)

2、统计数据库使用空间

select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='mydb';

| data |

| 6.64MB |

1 row in set (0.00 sec)

3、统计所有数据使用空间

select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables;

| data |

| 6.64MB |

1 row in set (0.01 sec)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值