進入information_schema 資料庫(存放了其他的資料庫的資訊)
use information_schema;
檢視所有庫的大小
mysql> use information_schema;
database changed
mysql> select concat(round(sum(data_length/1024/1024),2),'mb') as data
from tables;
+----------+
| data |
+----------+
| 104.21mb |
+----------+
1 row in set (0.11 sec)
檢視指定庫的大小
mysql> select concat(round(sum(data_length/1024/1024),2),'mb') as data
from tables where table_schema='jishi';
+---------+
| data |
+---------+
| 26.17mb |
+---------+
1 row in set (0.01 sec)
檢視指定庫的指定表的大小
mysql> select concat(round(sum(data_length/1024/1024),2),'mb') as data
from tables wheretable_schema='jishi' and table_name='a_ya';
+--------+
| data
|+--------+
| 0.02mb |
+--------+
1 row in set (0.00 sec)
檢視指定庫的索引大小
mysql> select concat(round(sum(index_length)/(1024*1024), 2), ' mb') as 'total index size' from tables
where table_schema = 'jishi';
+------------------+
| total index size |
+------------------+
| 0.94 mb |
+------------------+
1 row in set (0.01 sec)
檢視指定庫的指定表的索引大小
mysql> select concat(round(sum(index_length)/(1024*1024), 2), ' mb') as 'total index size' from tables
where table_schema = 'test' and table_name='a_yuser';
+------------------+
| total index size |
+------------------+
| 21.84 mb
|+------------------+
1 row in set (0.00 sec)
mysql 檢視 庫 表 大小
mysql 檢視 庫 表 大小 查詢所有資料的大小 use information schema select concat sum data length index length 1024 1024 mb 庫內表大小 from tables 檢視指定資料庫的大小,比如說 資料庫test use ...
mysql檢視資料庫大小或者表大小
要想知道每個資料庫的大小的話,步驟如下 1 進入information schema 資料庫 存放了資料庫的資訊 use information schema 2 查詢所有資料庫的大小 select concat round sum data length 1024 1024 2 mb as dat...
MYSQL 檢視資料庫大小以及表的大小
在mysql的information schema資料庫下執行 一 檢視每個資料庫的大小 select table schema,concat round sum data length 1024 1024 2 mb as data from tables group by table schema...