一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

Mysql|Sql Server|Oracle|Redis|MongoDB|PostgreSQL|Sqlite|DB2|mariadb|Access|數(shù)據(jù)庫技術(shù)|

服務(wù)器之家 - 數(shù)據(jù)庫 - Mysql - Mysql 查詢數(shù)據(jù)庫容量大小的方法步驟

Mysql 查詢數(shù)據(jù)庫容量大小的方法步驟

2021-01-21 16:35Jevic Mysql

這篇文章主要介紹了Mysql 查詢數(shù)據(jù)庫容量大小的方法步驟,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

查詢所有數(shù)據(jù)庫的總大小

方法如下:

?
1
2
3
4
5
6
7
8
mysql> use information_schema;
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)

統(tǒng)計一下所有庫數(shù)據(jù)量

每張表數(shù)據(jù)量=AVG_ROW_LENGTH*TABLE_ROWS+INDEX_LENGTH

?
1
2
3
SELECT
SUM(AVG_ROW_LENGTH*TABLE_ROWS+INDEX_LENGTH)/1024/1024 AS total_mb
FROM information_schema.TABLES

統(tǒng)計每個庫大小:

?
1
2
3
SELECT
table_schema,SUM(AVG_ROW_LENGTH*TABLE_ROWS+INDEX_LENGTH)/1024/1024 AS total_mb
FROM information_schema.TABLES group by table_schema;

第二種情況:查看指定數(shù)據(jù)庫的大小,比如說:數(shù)據(jù)庫test,方法如下:

?
1
2
3
4
5
6
7
8
mysql> use information_schema;
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)

1.查看所有數(shù)據(jù)庫各容量大小

?
1
2
3
4
5
6
7
8
select
table_schema as '數(shù)據(jù)庫',
sum(table_rows) as '記錄數(shù)',
sum(truncate(data_length/1024/1024, 2)) as '數(shù)據(jù)容量(MB)',
sum(truncate(index_length/1024/1024, 2)) as '索引容量(MB)'
from information_schema.tables
group by table_schema
order by sum(data_length) desc, sum(index_length) desc;

2.查看所有數(shù)據(jù)庫各表容量大小

?
1
2
3
4
5
6
7
8
select
table_schema as '數(shù)據(jù)庫',
table_name as '表名',
table_rows as '記錄數(shù)',
truncate(data_length/1024/1024, 2) as '數(shù)據(jù)容量(MB)',
truncate(index_length/1024/1024, 2) as '索引容量(MB)'
from information_schema.tables
order by data_length desc, index_length desc;

3.查看指定數(shù)據(jù)庫容量大小

?
1
2
3
4
5
6
7
8
例:查看mysql庫容量大小
select
table_schema as '數(shù)據(jù)庫',
sum(table_rows) as '記錄數(shù)',
sum(truncate(data_length/1024/1024, 2)) as '數(shù)據(jù)容量(MB)',
sum(truncate(index_length/1024/1024, 2)) as '索引容量(MB)'
from information_schema.tables
where table_schema='mysql'; 

4.查看指定數(shù)據(jù)庫各表容量大小

?
1
2
3
4
5
6
7
8
9
10
11
例:查看mysql庫各表容量大小
 
select
table_schema as '數(shù)據(jù)庫',
table_name as '表名',
table_rows as '記錄數(shù)',
truncate(data_length/1024/1024, 2) as '數(shù)據(jù)容量(MB)',
truncate(index_length/1024/1024, 2) as '索引容量(MB)'
from information_schema.tables
where table_schema='mysql'
order by data_length desc, index_length desc;

題外方法

直接用shell命令統(tǒng)計mysql data目錄中的大小(注意只有庫,不包含數(shù)據(jù)庫日志大小)

備注 :

data_length :存儲數(shù)據(jù)大小

data_length/1024/1024:將字節(jié)轉(zhuǎn)換為MB

round(sum(data_length/1024/1024),2):取兩位小數(shù)

concat(round(sum(data_length/1024/1024),2),'MB') :給計算結(jié)果追加單位 “MB”

到此這篇關(guān)于Mysql 查詢數(shù)據(jù)庫容量大小的方法步驟的文章就介紹到這了,更多相關(guān)Mysql 查詢數(shù)據(jù)庫容量大小內(nèi)容請搜索服務(wù)器之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持服務(wù)器之家!

原文鏈接:https://segmentfault.com/a/1190000022874702

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 日韩夫妻性生活 | 色噜噜视频影院 | 俄罗斯bbbbbbbbb大片 | 国产私拍精品88福利视频 | 久久伊人影视 | 国产一级毛片潘金莲的奶头 | 99精品国产在现线免费 | 涩情主播在线翻车 | 亚洲精品一区在线观看 | 欧美人成绝费网站色www吃脚 | 亚洲AV永久无码精品澳门 | 香蕉国产成版人视频在线观看 | 放荡女小洁的性日记 | 18国产精品白浆在线观看免费 | 1024日韩基地 | 色欲麻将 | 亚洲第一综合网 | 国产欧美日韩综合 | 久久免费资源福利资源站 | 亚洲欧美日韩国产一区二区精品 | 精品国产91高清在线观看 | 欧美肥胖老妇做爰变态 | 日b视频免费 | 我和黑色丝袜班主任 | 日本xxxxn1819 | 精品精品国产自在现拍 | chinaese中国女人厕所小便 | 免费在线视频观看 | 99久久精品无码一区二区毛片 | 日本阿v在线播放 | 国产精品13p | 国内交换一区二区三区 | 天堂8在线天堂bt | 完整秽淫刺激长篇小说 | 三级黄色片在线免费观看 | 毛片免费观看的视频 | 亚洲欧洲综合 | 久久re热在线视频精99 | 国产成人久久精品推最新 | 亚洲精品一区二区观看 | 国产婷婷成人久久av免费高清 |