To view the MySQL database size using SQL commands

Source: Internet
Author: User

Mysql>MySQL>  UseInformation_schema;/*switch to INFORMATION_SCHEMA data*/     Databasechanged MySQL>MySQL> SelectConcatround(sum(Data_length/1024x768/1024x768),2),'MB') asData fromTables/*querying all data sizes*/     +----------+  |Data|  +----------+  | 123.68MB|  +----------+  1Rowinch Set(0.36sec) MySQL> SelectConcatround(sum(Data_length/1024x768/1024x768),2),'MB') asData fromTableswhereTable_schema='Hrkip';/*querying data size with database name "Hrkip"*/   +--------+  |Data|  +--------+  | 8.65MB|  +--------+  1Rowinch Set(0.00sec) MySQL> SelectConcatround(sum(Data_length/1024x768/1024x768),2),'MB') asData fromTableswhereTable_schema='Hrkip'  andtable_name='JX_LSJL';/*Query database name "Hrkip", data size with table named "Jx_lsjl "*/   +--------+  |Data|  +--------+  | 6.77MB|  +--------+  1Rowinch Set(0.00sec)

Note:

Data_length: Storing Data size

data_length/1024/1024: Convert bytes to MB

Round (sum (data_length/1024/1024), 2): Take Two decimal places

Concat (Round (sum (data_length/1024/1024), 2), ' MB '): Append unit "MB" to the result of the calculation

View MySQL database size using SQL commands

Related Article

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.