zoukankan      html  css  js  c++  java
  • 【转】MySQL查看表占用空间大小(转)

    //先进去MySQL自带管理库:information_schema   
    //自己的数据库:rokid_cas_music_test  
    //自己的表:data_song_thirdparty  
      
    mysql> use information_schema;  
    Database changed  
    mysql> select data_length,index_length  
        from information_schema.tables where table_schema='rokid_cas_music_test' and table_name = 'data_song_thirdparty'; 

    +-------------+--------------+
    | data_length | index_length |
    +-------------+--------------+
    | 15993798656 | 8825700352 |
    +-------------+--------------+
    1 row in set (0.00 sec)

    
    row in set (0.02 sec)  
      
    mysql> select concat(round(sum(data_length/1024/1024),2),'MB') as data_length_MB,  
        concat(round(sum(index_length/1024/1024),2),'MB') as index_length_MB  
        from information_schema.tables where  
        table_schema='rokid_cas_music_test'  
        and table_name = 'data_song_thirdparty';  
    

    +----------------+-----------------+
    | data_length_MB | index_length_MB |
    +----------------+-----------------+
    | 15252.88MB | 8416.84MB |
    +----------------+-----------------+
    1 row in set (0.01 sec)

    
    row in set (0.03 sec)

    查询MySQL数据库中每个数据库数据和索引所占的数据大小,单位G,保留两位小数

    select table_schema,round(sum(data_length)/1024/1024/1024,3) as datasize, round(sum(index_length)/1024/1024/1024,3) as indexsize
    from information_schema.tables
    where table_schema != 'information_schema' and table_schema != 'mysql' and table_schema != 'performance_schema'
    group by table_schema
    order by datasize desc;

    查询MySQL数据库中每个表的数据和索引所占的数据大小,单位G,保留两位小数

    select table_schema,table_name,round(sum(data_length)/1024/1024/1024,3) as datasize, round(sum(index_length)/1024/1024/1024,3) as indexsize
    from information_schema.tables
    where table_schema != 'information_schema' and table_schema != 'mysql' and table_schema != 'performance_schema'
    group by table_schema,table_name
    order by datasize desc;

    【转自】:http://www.cnblogs.com/qq78292959/archive/2012/12/26/2833698.html

  • 相关阅读:
    逐点分析,这样做Web端性能测试
    如何完成大数据测试-从功能测试角度分析
    自动化测试和手动测试利弊
    (一)SQL注入漏洞测试的方式总结
    如何设计一个完整的测试用例
    测试与开发、产品、上下级沟通、
    黑盒测试用例设计总结
    改变测试思路,你的性能测试才能更值钱!(下)
    20190923-03Linux时间日期类 000 011
    20190923-02Linux文件目录类 000 010
  • 原文地址:https://www.cnblogs.com/zhzhang/p/7248170.html
Copyright © 2011-2022 走看看