mysql>
mysql> use information_schema ; /*切換到information_schema資料下*/
database changed
mysql>
mysql> select concat(round(sum(data_length/1024/1024),2),'mb') as data from tables; /*查詢所有資料大小*/
+----------+
| data |
+----------+
| 123.68mb |
+----------+
1 row in set (0.36 sec)
mysql> select concat(round(sum(data_length/1024/1024),2),'mb') as data from tables where table_schema='hrkip'; /*查詢資料庫名稱為「hrkip」的資料大小*/
+--------+
| data |
+--------+
| 8.65mb |
+--------+
1 row in set (0.00 sec)
mysql> select concat(round(sum(data_length/1024/1024),2),'mb') as data from tables where table_schema='hrkip' and table_name='jx_lsjl' ; /*查詢資料庫名稱為「hrkip」,表名為「 jx_lsjl」的資料大小*/
+--------+
| data |
+--------+
| 6.77mb |
+--------+
1 row in set (0.00 sec)
mysql>
備註 :
data_length :儲存資料大小
data_length/1024/1024:將位元組轉換為mb
round(sum(data_length/1024/1024),2):取兩位小數
concat(round(sum(data_length/1024/1024),2),'mb') :給計算結果追加單位 「mb」
Mysql用SQL命令檢視Mysql資料庫大小
要想知道每個資料庫的大小的話,步驟如下 1 進入information schema 資料庫 存放了其他的資料庫的資訊 use information schema 2 查詢所有資料的大小 select concat round sum data length 1024 1024 2 mb as d...
Mysql之EXPLAIN命令檢視SQL執行計畫
root vm 0 5 centos mysqldumpslow a var log mariadb slow query log.txt reading mysql slow query log from var log mariadb slow query log.txt count 4 tim...
使用SQL命令檢視MYSQL資料庫大小
mysql mysql use information schema 切換到information schema資料下 database changed mysql mysql select concat round sum data length 1024 1024 2 mb as data fr...