亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

mysql 查看表大小的方法實(shí)踐

 更新時(shí)間:2023年01月05日 17:05:55   作者:wuchongyong  
本文主要介紹了mysql 查看表大小的方法實(shí)踐,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧

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

select
table_schema as '數(shù)據(jù)庫(kù)',
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ù)庫(kù)各表容量大小

select
table_schema as '數(shù)據(jù)庫(kù)',
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ù)庫(kù)容量大小

例:查看mysql庫(kù)容量大?。捍a如下:

select
table_schema as '數(shù)據(jù)庫(kù)',
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ù)庫(kù)各表容量大小*

例:查看mysql庫(kù)各表容量大小

select
table_schema as '數(shù)據(jù)庫(kù)',
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;

PS:查看MySql數(shù)據(jù)空間使用情況:

information_schema是MySQL的系統(tǒng)數(shù)據(jù)庫(kù),information_schema里的tables表存放了整個(gè)數(shù)據(jù)庫(kù)各個(gè)表的使用情況。

可以使用sql來(lái)統(tǒng)計(jì)出數(shù)據(jù)庫(kù)的空間使用情況,相關(guān)字段:

  • table_schema:數(shù)據(jù)庫(kù)名
  • table_name:表名
  • table_rows:記錄數(shù)
  • data_length:數(shù)據(jù)大小
  • index_length:索引大小

使用空間

1、統(tǒng)計(jì)表使用空間

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ù)庫(kù)使用空間

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ù)使用空間

select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables;

| data |

| 6.64MB |

1 row in set (0.01 sec)

 到此這篇關(guān)于mysql 查看表大小的方法實(shí)踐的文章就介紹到這了,更多相關(guān)mysql 查看表大小內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論