在mysql中查看數據庫與表的大小的方法

有需要的朋友,可以參考下
 

可以按如下的具體步驟,查詢數據庫的大小,如下:
1、進入information_schema 數據庫(存放了其他的數據庫的信息)
 

use information_schema;
 
 

 

2、查詢所有數據的大小:
 

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

 

3、查看指定數據庫的大小,(比如查看數據庫test_db的大小):
 

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

4、查看指定數據庫的某個表的大小(查看數據庫test_db中 members 表的大小):
 

select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='test_db' and table_name='members';
 5、查看每個數據庫的大小

 

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

 

就介紹這些了,希望對大家有所幫助。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章