MySQL Common query

Source: Internet
Author: User

Database

1. Query the size of all data: data_length: Data size index_length: Index size

SELECT concat (Round (sum (data_length+index_length)/1024/1024,2), ' MB ') as DATA from INFORMATION_SCHEMA. Tables\g

2. View the size of the specified database, such as the size of the database Zabbix:

SELECT concat (Round (sum (data_length+index_length)/1024/1024,2), ' MB ') as DATA from INFORMATION_SCHEMA. TABLES where table_schema= ' Zabbix ' \g

  

3. View the size of a table in the specified database, such as viewing the size of the history table in the database Zabbix

SELECT concat (Round (sum (data_length+index_length)/1024/1024,2), ' MB ') as DATA from INFORMATION_SCHEMA. TABLES where table_schema= ' Zabbix ' and table_name= ' History_uint ' \g

  

4. View all information related to the specified table

SELECT * FROM INFORMATION_SCHEMA. TABLES where table_schema= ' Zabbix ' and table_name= ' history ' \g

Table

1. Query the first line of records:

SELECT * from table limit 1;

2. Query the first n rows of records

SELECT * from table limit 10;

Or

SELECT * FROM table limit 0, 10;

  

MySQL Common query

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.