How to View mysql tablespaces and indexes _ MySQL

Source: Internet
Author: User
How to View mysql tablespaces and indexes: bitsCN. com1. view indexes

(1) unit: GB

Select concat (ROUND (SUM (index_length)/(1024*1024*1024), 2), 'GB') AS 'total Index size' FROM information_schema.TABLES WHERE table_schema LIKE 'database ';
+ ------------------ +
| Total Index Size |
+ ------------------ +
| 1.70 GB |
+ ------------------ +

(2) The unit is MB.

Select concat (ROUND (SUM (index_length)/(1024*1024), 2), 'mb') AS 'total Index size' FROM information_schema.TABLES WHERE table_schema LIKE 'database ';

"Database" indicates the database you want to view.



2. View tablespaces

Select concat (ROUND (SUM (data_length)/(1024*1024*1024), 2), 'GB') AS 'total Data size'
FROM information_schema.TABLES WHERE table_schema LIKE 'database ';
+ ----------------- +
| Total Data Size |
+ ----------------- +
| 3.01 GB |
+ ----------------- +

3. view information about all tables in the database

Select concat (table_schema, '.', table_name) AS 'table name ',
CONCAT (ROUND (table_rows/Rows), 'M') AS 'number of Rows ',
CONCAT (ROUND (data_length/(1024*1024*1024), 2), 'g') AS 'data size ',
CONCAT (ROUND (index_length/(1024*1024*1024), 2), 'g') AS 'index size ',
CONCAT (ROUND (data_length + index_length)/(1024*1024*1024), 2), 'g') AS 'total' FROM information_schema.TABLES WHERE table_schema LIKE 'database'; bitsCN.com

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.