content_image/670142.jpg
SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME = ’t1’; 

COALESCE PARTITION  can be used with a table that is partitioned by HASH  or KEY  to reduce the number of partitions by number . Suppose that you have created table t2  as follows: 

CREATE TABLE t2 ( name VARCHAR (30), started DATE ) PARTITION BY HASH( YEAR(started) ) PARTITIONS 6; 

To reduce the number of partitions used by t2  from 6 to 4, use the following statement: 

ALTER TABLE t2 COALESCE PARTITION 2; 

The data contained in the last number  partitions is merged into the remaining partitions. In this case, partitions 4 and 5 are merged into the first 4 partitions (the partitions numbered 0, 1, 2, and 3). 

To change some but not all the partitions used by a partitioned table, you can use REORGANIZE PARTITION . This statement can be used in several ways: 

•To merge a set of partitions into a single partition. This is done by naming several partitions in the partition_names  list and supplying a single definition for partition_definition . 

•To split an existing partition into several partitions. Accomplish this by naming a single partition for partition_names  and providing multiple partition_definitions . 

•To change the ranges for a subset of partitions defined using VALUES LESS THAN  or the value lists for a subset of partitions defined using VALUES IN . 

<img src='content_image/670142.jpg'>

## Note 

For partitions that have not been explicitly named, MySQL automatically provides the default names p0 , p1 , p2 , and so on. The same is true with regard to subpartitions. 

For more detailed information about and examples of ALTER TABLE ... REORGANIZE PARTITION statements, see Section 24.3.1, “Management of RANGE and LIST Partitions” . 

•To exchange a table partition or subpartition with a table, use the ALTER TABLE ... EXCHANGE PARTITION  statement—that is, to move any existing rows in the partition or subpartition to the nonpartitioned table, and any existing rows in the nonpartitioned table to the table partition or subpartition. 

For usage information and examples, see Section 24.3.3, “Exchanging Partitions and Subpartitions with Tables” . 

•Several options provide partition maintenance and repair functionality analogous to that implemented for nonpartitioned tables by statements such as CHECK TABLE  and REPAIR TABLE  (which are also supported for partitioned tables; for more information, see Section 13.7.3, “Table Maintenance Statements” ). These include ANALYZE PARTITION , CHECK PARTITION , OPTIMIZE PARTITION , REBUILD PARTITION , and REPAIR PARTITION . Each of these options takes a partition_names clause consisting of one or more names of partitions, separated by commas. The partitions must already exist in the target table. You can also use the ALL  keyword in place of partition_names , in which 

