吴峰的博客

mysql查询各数据库,数据表的容量大小,使用delete删除数据之后发现data_length存在缓存问题。解决办法使用 :TRUNCATE TABLE 表名;重新查询data_length发现数据已变化。

1.查看所有数据库容量大小

  selecttable_schema as '数据库',sum(table_rows) as '记录数',

sum(truncate(data_length/1024/1024, 2)) as '数据容量(MB)',sum(truncate(index_length/1024/1024, 2)) as

 '索引容量(MB)'from information_schema.tablesgroup by table_schemaorder by 

sum(data_length) desc, sum(index_length) desc;

2.查看所有数据库各表容量大小

selecttable_schema as '数据库',table_name as '表名',table_rows as '记录数',
truncate(data_length/1024/1024, 2) as '数据容量(MB)',truncate(index_length/1024/1024, 2) as 
'索引容量(MB)'from information_schema.tablesorder by data_length desc, index_length desc;

  

3.查看指定数据库容量大小

例:查看mysql库容量大小

selecttable_schema as '数据库',sum(table_rows) as '记录数',
sum(truncate(data_length/1024/1024, 2)) as '数据容量(MB)',sum(truncate(index_length/1024/1024, 2)) as 
'索引容量(MB)'from information_schema.tableswhere table_schema='mysql';

  

4.查看指定数据库各表容量大小

例:查看mysql库各表容量大小

selecttable_schema as '数据库',table_name as '表名',table_rows as '记录数',
truncate(data_length/1024/1024, 2) as '数据容量(MB)',truncate(index_length/1024/1024, 2) as 
'索引容量(MB)'from information_schema.tableswhere table_schema='mysql'order by 
data_length desc, index_length desc;
Tags:
评论 (6)
  • Gisele Creswick

    Gisele Creswick

    DataList2023.com presents all the new leads for you per country! Visit us on DataList2023.com

  • Arletha Macias

    Arletha Macias

    Hello, MegaLeadsTree.com is shutting down. We have made available all our leads in 145 countries at a one-time fee. Visit us on MegaLeadsTree.com.

  • Dorris Dedman

    Dorris Dedman

    Your go-to source for leads. We can provide business to business and business to consumer leads, custom-tailored to your needs. CustomDatabases.org

  • Tobias Cabrera

    Tobias Cabrera

    Hello, from CustomData.click we are a provider of unique databases that could help your business. Please visit us at CustomData.click to see if we can help you. Regards, Tobias

  • Lilla Carrington

    Lilla Carrington

    Hello. It is with sad regret to inform you TopDataList.com is shutting down. We have made all our databases available for you for a once off fee. Visit us on TopDataList.com

  • Raul Storkey

    Raul Storkey

    ZippyLeads.org is running an easter special till the 18th of April. Get all the leads you need for your company with our easter special.

  • 说点什么吧... (取消回复)

    正在加载验证码......

    请先拖动验证码到相应位置

Copyright 吴峰的博客 © 2014-2016 管理员邮箱:phpwufeng@163.com   统计:   ICP备案:鲁ICP备16004939号-1