zoukankan      html  css  js  c++  java
  • mysql查看某库表大小

    查询所有数据库占用磁盘空间大小的SQL语句:

    语句如下

    1
    2
    3
    4
    5
    select TABLE_SCHEMA, concat(truncate(sum(data_length)/1024/1024,2),' MB') as data_size,
    concat(truncate(sum(index_length)/1024/1024,2),'MB') as index_size
    from information_schema.tables
    group by TABLE_SCHEMA
    order by data_length desc;

      

    执行结果如下

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    mysql> select TABLE_SCHEMA, concat(truncate(sum(data_length)/1024/1024,2),' MB') as data_size,
    concat(truncate(sum(index_length)/1024/1024,2),'MB') as index_size
    from information_schema.tables
    group by TABLE_SCHEMA
    order by data_length desc;
    +--------------------+------------+------------+
    | TABLE_SCHEMA       | data_size  | index_size |
    +--------------------+------------+------------+
    | shdx               | 1042.38 MB | 258.97MB   |
    | mysql              | 0.52 MB    | 0.08MB     |
    | information_schema | 0.00 MB    | 0.00MB     |
    +--------------------+------------+------------+
    3 rows in set
     
    mysql>

      

    查询单个库中所有表磁盘占用大小的SQL语句:

    执行语句如下

    1
    2
    3
    4
    5
    select TABLE_NAME, concat(truncate(data_length/1024/1024,2),' MB'as data_size,
    concat(truncate(index_length/1024/1024,2),' MB'as index_size
    from information_schema.tables where TABLE_SCHEMA = 'TestDB'
    group by TABLE_NAME
    order by data_length desc;

    以上语句测试有效,注意替换以上的TestDB为数据库名 

    执行结果如下,截取部分

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    mysql> select TABLE_NAME, concat(truncate(data_length/1024/1024,2),' MB'as data_size,
    concat(truncate(index_length/1024/1024,2),' MB'as index_size
    from information_schema.tables where TABLE_SCHEMA = 'shdx'
    group by TABLE_NAME
    order by data_length desc;
    +--------------------------------+-----------+------------+
    | TABLE_NAME                     | data_size | index_size |
    +--------------------------------+-----------+------------+
    | tab_automatch_log              | 499.08 MB | 95.03 MB   |
    | tab_fundlog201505              | 101.96 MB | 19.13 MB   |
    | tab_online                     | 63.49 MB  | 14.32 MB   |
    | tab_game_record201505          | 56.97 MB  | 30.93 MB   |
    | tab_user                       | 52.17 MB  | 12.31 MB   |
    | dc_user_action_active          | 39.94 MB  | 0.00 MB    |
    | tab_gametime_day               | 37.22 MB  | 21.50 MB   |
    | tab_fundlog                    | 35.12 MB  | 6.45 MB    |
    | tab_game_record                | 19.85 MB  | 10.56 MB   |
    | tab_feeaccount                 | 19.17 MB  | 10.75 MB   |
    | tab_userinfo                   | 18.78 MB  | 6.33 MB    |
    | tab_userfund                   | 17.91 MB  | 9.51 MB    |
    | tab_click_count                | 14.63 MB  | 1.75 MB    |
    | tab_achievement_log            | 10.51 MB  | 1.36 MB    |
    | tab_gameloginlog201505         | 5.78 MB   | 0.75 MB    |
    | tab_gametime                   | 4.29 MB   | 3.16 MB    |
    | tab_gameloginlog               | 3.83 MB   | 0.50 MB    |
    | tab_login_log201505            | 2.79 MB   | 0.67 MB    |
    | tab_system_operatelog          | 2.74 MB   | 0.19 MB    |
    | tab_singleplay_score           | 2.10 MB   | 0.28 MB    |
    | tab_game_record201301          | 1.93 MB   | 1.08 MB    |
    | tab_game_score_shddz           | 1.61 MB   | 0.80 MB    |
    | tab_game_score_ddz             | 1.39 MB   | 0.66 MB    |
    | tab_game_score_shmj            | 1.34 MB   | 0.67 MB    |
    | tab_game_xyzdx_getscore_detail | 1.28 MB   | 0.21 MB    |

      

    参考链接

    http://www.jb51.net/article/40789.htm

  • 相关阅读:
    编码和字符集
    【机器学习】模型泛化
    asp.net GridView控件的列属性
    asp.net截取指定长度的字符串内容
    asp.net 对数据库表增加,删除,编辑更新修改
    asp.net 链接数据库ADO.NET
    常用正则表达式 验证电子邮件网址邮政编码等
    ASP.NET获取文件的相关知识
    C#获取picturebox图片路径
    C# dataGridView根据数据调整列宽
  • 原文地址:https://www.cnblogs.com/wangjizhen/p/9447208.html
Copyright © 2011-2022 走看看