1、查詢整個(gè)mysql數(shù)據(jù)庫(kù),整個(gè)庫(kù)的大?。粏挝晦D(zhuǎn)換為MB。
成都創(chuàng)新互聯(lián)公司是一家專注于成都做網(wǎng)站、成都網(wǎng)站制作、成都外貿(mào)網(wǎng)站建設(shè)與策劃設(shè)計(jì),惠安網(wǎng)站建設(shè)哪家好?成都創(chuàng)新互聯(lián)公司做網(wǎng)站,專注于網(wǎng)站建設(shè)十多年,網(wǎng)設(shè)計(jì)領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:惠安等地區(qū)?;莅沧鼍W(wǎng)站價(jià)格咨詢:028-86922220
select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data? from information_schema.TABLES
2、查詢mysql數(shù)據(jù)庫(kù),某個(gè)庫(kù)的大小;
select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data
from information_schema.TABLES
where table_schema = 'testdb'
3、查看庫(kù)中某個(gè)表的大?。?/p>
select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data
from information_schema.TABLES
where table_schema = 'testdb'
and table_name = 'test_a';
4、查看mysql庫(kù)中,test開頭的表,所有存儲(chǔ)大?。?/p>
select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data
from information_schema.TABLES
where table_schema = 'testdb'
and table_name like 'test%';
首先打開指定的數(shù)據(jù)庫(kù):
use
information_schema;
如果想看指定數(shù)據(jù)庫(kù)中的數(shù)據(jù)表,可以用如下語(yǔ)句:
select
concat(round(sum(DATA_LENGTH/1024/1024),2),'MB')
as
data
from
TABLES
where
table_schema='AAAA'
and
table_name='BBBB';
如果想看數(shù)據(jù)庫(kù)中每個(gè)數(shù)據(jù)表的,可以用如下語(yǔ)句:
SELECT
TABLE_NAME,DATA_LENGTH+INDEX_LENGTH,TABLE_ROWS,concat(round((DATA_LENGTH+INDEX_LENGTH)/1024/1024,2),
'MB')
as
data
FROM
TABLES
WHERE
TABLE_SCHEMA='AAAA';
輸出:
1、進(jìn)去指定schema 數(shù)據(jù)庫(kù)(存放了其他的數(shù)據(jù)庫(kù)的信息)
use information_schema
2、查詢所有數(shù)據(jù)的大小
select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data from TABLES
3、查看指定數(shù)據(jù)庫(kù)的大小
比如說(shuō) 數(shù)據(jù)庫(kù)apoyl
select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data from TABLES where table_schema='apoyl';
4、查看指定數(shù)據(jù)庫(kù)的表的大小
比如說(shuō) 數(shù)據(jù)庫(kù)apoyl 中apoyl_test表
select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data from TABLES where table_schema='apoyl' and table_name='apoyl_test';
整完了,有興趣的可以試哈哦!挺使用哈
網(wǎng)站找的,都是正解
如題,找到MySQL中的information_schema表,這張表記錄了所有數(shù)據(jù)庫(kù)中表的信息,主要字段含義如下:
TABLE_SCHEMA : 數(shù)據(jù)庫(kù)名
TABLE_NAME:表名
ENGINE:所使用的存儲(chǔ)引擎
TABLES_ROWS:記錄數(shù)
DATA_LENGTH:數(shù)據(jù)大小
INDEX_LENGTH:索引大小
如果需要查詢所有數(shù)據(jù)庫(kù)占用空間大小只需要執(zhí)行SQL命令:
mysql use information_schema
Database changed
mysql SELECT sum(DATA_LENGTH+INDEX_LENGTH) FROM TABLES;
+-------------------------------+
| sum(DATA_LENGTH+INDEX_LENGTH) |
+-------------------------------+
| 683993 |
+-------------------------------+
1 row in set (0.00 sec)
大小是字節(jié)數(shù) 如果想修改為KB可以執(zhí)行:
SELECT sum(DATA_LENGTH+INDEX_LENGTH)/1024 FROM TABLES;
如果修改為MB應(yīng)該也沒(méi)問(wèn)題了吧
如果需要查詢一個(gè)數(shù)據(jù)庫(kù)所有表的大小可以執(zhí)行:
SELECT sum(DATA_LENGTH+INDEX_LENGTH) FROM TABLES WHERE TABLE_SCHEMA='數(shù)據(jù)庫(kù)名'