Home > Database > Mysql Tutorial > body text

How to query partition table information in mysql

青灯夜游
Release: 2022-01-04 16:58:22
Original
30574 people have browsed it

Query method: 1. Use the "show create table table name" statement; 2. Use the "show table table name" statement; 3. Query the "information_schema.partitions" table to see which partitions the table has. , partitioning method, and recording of data in the partition.

How to query partition table information in mysql

The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.

Introduces several methods to obtain MySQL partition table information.

1. show create table table name

You can view the create of the partition table statement.

How to query partition table information in mysql

/*!...*/ is a special comment that other database products will not execute. MySQL special processing will be executed selectively. It can be thought of as: conditional compilation in precompilation. Pay special attention to 50100, which indicates version 5.01.00 or higher before execution.

2. show table status

You can check whether the table is a partitioned table.

How to query partition table information in mysql

3. Check the information_schema.partitions table

SELECT PARTITION_NAME,PARTITION_METHOD,PARTITION_EXPRESSION,PARTITION_DESCRIPTION,
TABLE_ROWS,SUBPARTITION_NAME,SUBPARTITION_METHOD,SUBPARTITION_EXPRESSION
FROM information_schema.PARTITIONS
WHERE TABLE_SCHEMA=SCHEMA() AND TABLE_NAME='TABLE_NAME';
Copy after login

to see which partitions the table has. Information such as the partition method, the number of data records in the partition, and even information about sub-partitions.

How to query partition table information in mysql

4. explain select or explain partitions select statement

Use this statement to display which partitions are scanned , and how they are used.

explain partitions select * from tb_sub2 where purchased='1989-01-01';
explain select * from tb_sub2 where purchased='1989-01-01';
Copy after login

The output results of the above two statements are the same.

How to query partition table information in mysql

[Related recommendations: mysql video tutorial]

The above is the detailed content of How to query partition table information in mysql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!