欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

mysql 查看表大小的方法實踐

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

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

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ù)庫各表容量大小

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ù)庫容量大小

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

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ù)庫各表容量大小*

例:查看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;

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

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

可以使用sql來統(tǒng)計出數(shù)據(jù)庫的空間使用情況,相關字段:

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

使用空間

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

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)計數(shù)據(jù)庫使用空間

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)計所有數(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)

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

您可能感興趣的文章:

相關文章

最新評論