mysql查看數(shù)據(jù)庫大小以及使用情況?
用SQL命令查看Mysql數(shù)據(jù)庫大小:
要想知道每個數(shù)據(jù)庫的大小的話,步驟如下:
1、進(jìn)入information_schema 數(shù)據(jù)庫(存放了其他的數(shù)據(jù)庫的信息)
use information_schema;
2、查詢所有數(shù)據(jù)的大小:
select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables;
3、查看指定數(shù)據(jù)庫的大小:
比如查看數(shù)據(jù)庫home的大小
select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='home';
4、查看指定數(shù)據(jù)庫的某個表的大小
比如查看數(shù)據(jù)庫home中 members 表的大小
select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='home' and table_name='members';
information_schema是MySQL的系統(tǒng)數(shù)據(jù)庫,information_schema里的tables表存放了整個數(shù)據(jù)庫各個表的使用情況。
可以使用sql來統(tǒng)計(jì)出數(shù)據(jù)庫的空間使用情況,相關(guān)字段:
table_schema:數(shù)據(jù)庫名
table_name:表名
table_rows:記錄數(shù)
data_length:數(shù)據(jù)大小
index_length:索引大小
1、統(tǒng)計(jì)表使用空間
mysql> select concat(round(sum(data_length/1024/1024),2),'mb') as data from tables where table_schema='mydb' and table_name='mytable';
| data |
| 0.02mb |
1 row in set (0.00 sec)
2、統(tǒng)計(jì)數(shù)據(jù)庫使用空間
mysql> select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='mydb';
| data |
| 6.64MB |
1 row in set (0.00 sec)
3、統(tǒng)計(jì)所有數(shù)據(jù)使用空間
mysql> select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables;
| data |
| 6.64MB |
1 row in set (0.01 sec)
以上就是mysql查看數(shù)據(jù)庫大小以及使用情況的全部內(nèi)容,供大家參考!
縱橫數(shù)據(jù)專業(yè)提供海外云服務(wù)器租用、動態(tài)撥號vps服務(wù)器租用、gpu顯卡服務(wù)器租用、站群服務(wù)器租用、高防服務(wù)器租用、CN2服務(wù)器租用、bgp服務(wù)器租用等,有需要的朋友可以咨詢我們,官網(wǎng):http://www.zonghengcloud.com/,QQ:3494196421,微信:19906048603。