檢視MySQL資料庫大小的方法總結

chenfeng發表於2017-01-17
進入information_schema 資料庫(存放了其他的資料庫的資訊)
mysql> use information_schema
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

 第一種情況:查詢所有資料庫的總大小,方法如下:
mysql> select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data from TABLES;
+-----------+
| data      |
+-----------+
| 3052.76MB |
+-----------+
1 row in set (0.02 sec)


 第二種情況:檢視指定資料庫的大小,比如說:資料庫test,方法如下:
mysql> select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data from TABLES where table_schema='test';
+----------+
| data     |
+----------+
| 142.84MB |
+----------+
1 row in set (0.00 sec)


 第三種:檢視指定資料庫的表的大小,比如說:資料庫test中f_apply表,方法如下:
mysql> select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data from TABLES where table_schema='ixinnuo_financial' and table_name='f_apply';
+--------+
| data   |
+--------+
| 0.08MB |
+--------+
1 row in set (0.00 sec)

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15498/viewspace-2132583/,如需轉載,請註明出處,否則將追究法律責任。

相關文章