本文摘自:https://www.2cto.com/database/201704/622142.html
mysql> use information_schema;
Database changed
mysql> select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data from TABLES;
结果:
mysql> select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data from TABLES where table_schema='CarData';
结果
mysql> select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data from TABLES where table_schema='CarData' and table_name='driver020294';
结果
查看指定数据库指定表单的其他大小:
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';
结果:
注:第一步也可以不用使用数据库,直接像下面这样写;
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';
结果是一样的:
“The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.” – Tom Cargill
标 题:查看mysql数据库大小