• 如何查看MySQL单个数据库或者表的大小


    总体来说,这些信息存在于information_schema数据库的TABLES表中

    mysql> desc information_schema.TABLES;
    +-----------------+---------------------+------+-----+---------+-------+
    | Field           | Type                | Null | Key | Default | Extra |
    +-----------------+---------------------+------+-----+---------+-------+
    | TABLE_CATALOG   | varchar(512)        | NO   |     |         |       |
    | TABLE_SCHEMA    | varchar(64)         | NO   |     |         |       |
    | TABLE_NAME      | varchar(64)         | NO   |     |         |       |
    | TABLE_TYPE      | varchar(64)         | NO   |     |         |       |
    | ENGINE          | varchar(64)         | YES  |     | NULL    |       |
    | VERSION         | bigint(21) unsigned | YES  |     | NULL    |       |
    | ROW_FORMAT      | varchar(10)         | YES  |     | NULL    |       |
    | TABLE_ROWS      | bigint(21) unsigned | YES  |     | NULL    |       |
    | AVG_ROW_LENGTH  | bigint(21) unsigned | YES  |     | NULL    |       |
    | DATA_LENGTH     | bigint(21) unsigned | YES  |     | NULL    |       |
    | MAX_DATA_LENGTH | bigint(21) unsigned | YES  |     | NULL    |       |
    | INDEX_LENGTH    | bigint(21) unsigned | YES  |     | NULL    |       |
    | DATA_FREE       | bigint(21) unsigned | YES  |     | NULL    |       |
    | AUTO_INCREMENT  | bigint(21) unsigned | YES  |     | NULL    |       |
    | CREATE_TIME     | datetime            | YES  |     | NULL    |       |
    | UPDATE_TIME     | datetime            | YES  |     | NULL    |       |
    | CHECK_TIME      | datetime            | YES  |     | NULL    |       |
    | TABLE_COLLATION | varchar(32)         | YES  |     | NULL    |       |
    | CHECKSUM        | bigint(21) unsigned | YES  |     | NULL    |       |
    | CREATE_OPTIONS  | varchar(255)        | YES  |     | NULL    |       |
    | TABLE_COMMENT   | varchar(2048)       | NO   |     |         |       |
    +-----------------+---------------------+------+-----+---------+-------+

    # check database size

    SELECT table_schema                                        "DB Name",     Round(Sum(data_length + index_length) / 1024 / 1024 / 1024, 1) "DB Size in GB"  FROM   information_schema.tables  GROUP  BY table_schema;

    # check table size

    SELECT table_schema as `Database`, table_name AS `Table`, round(((data_length + index_length) / 1024 / 1024 / 1024), 2) `Size in GB` FROM information_schema.TABLES where table_schema = 'purge_qms' ORDER BY (data_length + index_length) DESC ;

  • 相关阅读:
    数组返回NULL绕过
    69.x的平方根
    1277.统计全为1的正方形子矩形
    221.最大正方形
    572.另一个树的子树
    983.最低票价
    98.验证二叉排序树
    53.最大子序和
    5386.检查一个字符串是否可以打破另一个字符串
    5385.改变一个整数能得到的最大差值
  • 原文地址:https://www.cnblogs.com/shitouer/p/7573602.html
Copyright © 2020-2023  润新知