Mysql View Database size

Source: Internet
Author: User

1 command line access to database

[Email protected] ~]# mysql-uroot-penter Password:

2 Viewing the database

Mysql> Show databases;+--------------------+| Database |+--------------------+| Information_schema | | MySQL | | Test |+--------------------+

3 View Information_schema's "TABLES"

Mysql> Use information_schema;| TABLES |

4 Viewing the field structure

mysql> desc tables;+-----------------+---------------------+------+-----+---------+-------+|  Field           | Type                 | null | key  | default | extra |+-----------------+---------------------+------+-----+---------+ + ------+| table_catalog   | varchar (       )  | NO   |     |          |       | |  table_schema    | varchar (        )  | NO   |     |          |       | |  table_name  &nbsP;   | varchar (         | NO )   |     |         |        | |  table_type      | varchar (      )    | NO   |     |          |       | |  engine          | varchar (   )       | YES  |     | NULL     |       | |  version         | bigint (+)  unsigned |  yes  |     | null     |       | |  row_format      | varchar (Ten)           | yes  |     | null    |        | |  table_rows      | bigint (+)  unsigned | YES   |     | NULL    |        | |  avg_row_length  | bigint (+)  unsigned | YES  |      | null    |       | |  data_length     | bigint (+)  unsigned | yes  |      | null    |       | |  max_data_length | bigint (+)  unsigned | yes  |     | null    |        | |  index_length    | bigint (+)  unsigned | YES  |      | null    |       | |  data_free       | bigint (+)  unsigned | YES   |     | NULL    |        | |  auto_increment  | bigint (+)  unsigned | YES  |      | null    |       | |  CREATE_TIME     | datetime             | yes  |     | null    |       | |  UPDATE_TIME     | datetime             | YES  |     | NULL     |       | |  CHECK_TIME      | datetime             | YES  |     | NULL     |       | |  table_collation | varchar (+)          | yes   |     | NULL    |        | |  checksum        | bigint (+)  unsigned | YES   |     | null     |       | |  create_options  | varchar (255)         | yes   |     | NULL    |        | |  table_comment   | varchar (2048)        | no    |     |         |        |+-----------------+---------------------+------+-----+---------+--- ----+

5 Viewing the data size of the DB

Mysql> select table_schema,round (SUM (data_length)/1024/1024,2)  as table_size from  tables group by table_schema;+--------------------+------------+| table_schema        | table_size |+--------------------+------------+| bomo_ backend       |       0.09 | |  test1              |      234.16 | |  test2              |        0.17 | |  information_schema |       0.00 | |  mysql              |        0.71 | |  performance_schema |       0.00 | |  test               |        0.03 |+--------------------+------------+

6 Viewing the table's data size

Mysql> select table_schema,table_name,concat (Round (data_length/1024/1024,2), ' M ')  as  table_size from tables where table_schema =  ' grab '; +--------------+------------- -+------------+| table_schema | table_name   | table_size |+---------- ----+--------------+------------+| grab         |  product      | 215.12m    | |  grab         | result        | 13.52m     | |  grab         | rule          | 0.02m      | |  grab         | task          | 5.52m      |+--------------+--------------+------------+ 


This article from "Old Cannon Son" blog, reprint please contact the author!

Mysql View Database size

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.