zoukankan      html  css  js  c++  java
  • 如何查看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 ;

  • 相关阅读:
    C++ 11 Lambda表达式
    Hello word!
    nginx 官方文档翻译
    Http读书笔记1-5章
    ROM、RAM、DRAM、SRAM和FLASH的区别
    优化专题
    Typescript学习
    canvas实现的粒子效果
    【转载】js常用方法和片段
    【转载】图解正向代理、反向代理、透明代理
  • 原文地址:https://www.cnblogs.com/shitouer/p/7573602.html
Copyright © 2011-2022 走看看