• 【转】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

  • 相关阅读:
    windows系统设置虚拟机开机自启并运行虚拟系统
    Pycharm模板添加默认信息
    (翻译)从底层了解ASP.NET体系结构 [转]
    sql2000安装在win2003后只有在本机才能访问,局域网内其他机器不能访问
    Web上传文件的原理及实现[转]
    Http 请求处理流程[转]
    .net 必知
    sql2000数据库在企业管理器中显示置疑(suspect),在查询分析器不显示。在企业管理器中附加:提示错误823
    HTTP请求过程简介[转]
    面向对象
  • 原文地址:https://www.cnblogs.com/zhzhang/p/7248170.html
Copyright © 2020-2023  润新知