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

  • 相关阅读:
    phalcon之视图缓存
    Java NIO框架Netty教程(一) – Hello Netty
    setsockopt的作用
    支持向量机通俗导论(理解SVM的三层境地)
    quartz中的corn表达式(转)
    Applet 数字签名技术全然攻略
    SJTU 3001. 二哥的幸运
    OGRE之跳出漫长的编译等待
    VB.NET 数组的定义 动态使用 多维数组
    【Python】用Python的“结巴”模块进行分词
  • 原文地址:https://www.cnblogs.com/zhzhang/p/7248170.html
Copyright © 2011-2022 走看看