mysql 庫和表佔用空間查詢

來源:互聯網
上載者:User

標籤:mat   date   大小   row   color   gpo   size   ati   資料   

1. 查看該資料庫執行個體下所有庫大小,得到的結果是以MB為單位

select table_schema,sum(data_length)/1024/1024 as data_length,sum(index_length)/1024/1024as index_length,sum(data_length+index_length)/1024/1024 as sum from information_schema.tables;

 

2、查看該執行個體下各個庫大小

select table_schema, sum(data_length+index_length)/1024/1024 as total_mb,sum(data_length)/1024/1024 as data_mb, sum(index_length)/1024/1024 as index_mb,count(*) as tables, curdate() as today from information_schema.tables group by table_schema order by 2 desc;

 

3、查看單個庫的大小

select concat(truncate(sum(data_length)/1024/1024,2),‘mb‘) as data_size,concat(truncate(sum(max_data_length)/1024/1024,2),‘mb‘) as max_data_size,concat(truncate(sum(data_free)/1024/1024,2),‘mb‘) as data_free,concat(truncate(sum(index_length)/1024/1024,2),‘mb‘) as index_sizefrom information_schema.tables where table_schema = ‘jwtnew2017‘;

 

4、查看單個表的狀態

show table status from jwtnew2017 where name = ‘t_user‘

 

5、查看單庫下所有表的狀態

use infomation_schema;select table_name, (data_length/1024/1024) as data_mb , (index_length/1024/1024) as index_mb, ((data_length+index_length)/1024/1024) as all_mb, table_rowsfrom tables where table_schema = ‘mydb‘

 

mysql 庫和表佔用空間查詢

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.