查看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' ; |
结果是一样的:
学习时的痛苦是暂时的 未学到的痛苦是终生的