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

  • 相关阅读:
    各种筛法与莫比乌斯反演
    欧拉函数技巧与学习笔记
    莫比乌斯函数与欧拉函数的单个值的快速求法
    最短路算法总结
    NOI2018网络同步赛游记
    中国剩余定理及其扩展学习笔记
    构造方法的格式
    private关键字
    成员变量和局部变量的区别
    数据加密代码实现
  • 原文地址:https://www.cnblogs.com/zhzhang/p/7248170.html
Copyright © 2011-2022 走看看