查看mysql数据库体积

查看MySQL数据库大小

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

1
2
mysql> use information_schema;
Database changed

2.查看大小
(1)查看所有数据库大小

1
mysql> select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data from TABLES;

结果:
这里写图片描述
(2)查看指定数据库大小

1
mysql> select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data from TABLES where table_schema='CarData';

结果
这里写图片描述
(3)查看指定数据库的指定表单的大小

1
mysql> select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data from TABLES where table_schema='CarData' and table_name='driver020294';

结果
这里写图片描述

查看指定数据库指定表单的其他大小:

1
2
3
4
5
mysql> select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data_size,
    -> concat(round(sum(MAX_DATA_LENGTH/1024/1024),2),'MB') as max_data_size,
    -> concat(round(sum(INDEX_LENGTH/1024/1024),2),'MB') as index_size,
    -> concat(round(sum(DATA_FREE/1024/1024),2),'MB') as data_free
    -> from TABLES where table_schema='CarData' and table_name='driver020294';

结果:
这里写图片描述

注:第一步也可以不用使用数据库,直接像下面这样写;

1
2
3
4
5
mysql> select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data_size,
    -> concat(round(sum(MAX_DATA_LENGTH/1024/1024),2),'MB') as max_data_size,
    -> concat(round(sum(INDEX_LENGTH/1024/1024),2),'MB') as index_size,
    -> concat(round(sum(DATA_FREE/1024/1024),2),'MB') as data_free
    -> from INFORMATION_SCHEMA.TABLES where table_schema='CarData' and table_name='driver020294';

结果是一样的:
这里写图片描述

posted @ 2018-02-09 15:03  鸡毛巾  阅读(2924)  评论(0编辑  收藏  举报