MySQL obtains the database size.

Source: Internet
Author: User

1. Command Line

Preface:

To know the space occupied by a table, it is equivalent to the data size + index size.

Show databases; (view the number of databases, also known as table schema; it is a bit of a string)

1.1 view the size occupied by a single database (or table schema)

[SQL]

  1. Select Sum(DATA_LENGTH) +Sum(INDEX_LENGTH)FromInformation_schema.tables
  2. WhereTable_schema ='Database name';

The result is in bytes. If it is converted into megabytes, it is divided by 1024*1024.

Note: The information_schema database contains a lot of statistics for the entire database. You can view them to obtain database-related information.


Easy to understand, go to information_schema to view

[SQL]

  1. Use information_schema;
Next, ignore the index size.

1.2 query the size of all data

[SQL]

  1. SelectConcat (round (Sum(DATA_LENGTH/1024/1024), 2 ),'M')FromTables;
This will take longer.


1.3 view the size of a table in the database

[SQL]

  1. SelectConcat (round (Sum(DATA_LENGTH/1024/1024), 2 ),'M')FromTablesWhereTable_schema = 'database name'ANDTable_name = 'table name ';


2. View Software

You can install PhpMyAdmin or

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.