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

您所在的位置:网站首页 数据库的schema怎么看 mysql查看数据库大小以及使用情况?

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

2024-07-11 19:49| 来源: 网络整理| 查看: 265

一、用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)



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3