PDF (A4) - 35.2Mb
Man Pages (TGZ) - 256.4Kb
Man Pages (Zip) - 361.2Kb
Info (Gzip) - 3.4Mb
Info (Zip) - 3.4Mb
MySQL Globalization
MySQL Information Schema
MySQL Installation Guide
MySQL and Linux/Unix
MySQL and macOS
MySQL Partitioning
MySQL Performance Schema
MySQL Replication
Using the MySQL Yum Repository
MySQL Restrictions and Limitations
Security in MySQL
MySQL and Solaris
Building MySQL from Source
Starting and Stopping MySQL
MySQL Tutorial
MySQL and Windows
MySQL NDB Cluster 7.5
MySQL 5.7 provides a number of ways to modify partitioned tables. It is possible to add, drop, redefine, merge, or split existing partitions. All of these actions can be carried out using the partitioning extensions to theALTER TABLE statement. There are also ways to obtain information about partitioned tables and partitions. We discuss these topics in the sections that follow.
For information about partition management in tables partitioned by
RANGEorLIST, seeSection 22.3.1, “Management of RANGE and LIST Partitions”.For a discussion of managing
HASHandKEYpartitions, seeSection 22.3.2, “Management of HASH and KEY Partitions”.SeeSection 22.3.5, “Obtaining Information About Partitions”, for a discussion of mechanisms provided in MySQL 5.7 for obtaining information about partitioned tables and partitions.
For a discussion of performing maintenance operations on partitions, seeSection 22.3.4, “Maintenance of Partitions”.
In MySQL 5.7, all partitions of a partitioned table must have the same number of subpartitions, and it is not possible to change the subpartitioning once the table has been created.
To change a table's partitioning scheme, it is necessary only to use theALTER TABLE statement with apartition_options clause. This clause has the same syntax as that as used withCREATE TABLE for creating a partitioned table, and always begins with the keywordsPARTITION BY. Suppose that you have a table partitioned by range using the followingCREATE TABLE statement:
CREATE TABLE trb3 (id INT, name VARCHAR(50), purchased DATE) PARTITION BY RANGE( YEAR(purchased) ) ( PARTITION p0 VALUES LESS THAN (1990), PARTITION p1 VALUES LESS THAN (1995), PARTITION p2 VALUES LESS THAN (2000), PARTITION p3 VALUES LESS THAN (2005) ); To repartition this table so that it is partitioned by key into two partitions using theid column value as the basis for the key, you can use this statement:
ALTER TABLE trb3 PARTITION BY KEY(id) PARTITIONS 2; This has the same effect on the structure of the table as dropping the table and re-creating it usingCREATE TABLE trb3 PARTITION BY KEY(id) PARTITIONS 2;.
ALTER TABLE ... ENGINE = ... changes only the storage engine used by the table, and leaves the table's partitioning scheme intact. UseALTER TABLE ... REMOVE PARTITIONING to remove a table's partitioning. SeeSection 13.1.8, “ALTER TABLE Statement”.
Only a singlePARTITION BY,ADD PARTITION,DROP PARTITION,REORGANIZE PARTITION, orCOALESCE PARTITION clause can be used in a givenALTER TABLE statement. If you (for example) wish to drop a partition and reorganize a table's remaining partitions, you must do so in two separateALTER TABLE statements (one usingDROP PARTITION and then a second one usingREORGANIZE PARTITION).
In MySQL 5.7, it is possible to delete all rows from one or more selected partitions usingALTER TABLE ... TRUNCATE PARTITION.
PDF (A4) - 35.2Mb
Man Pages (TGZ) - 256.4Kb
Man Pages (Zip) - 361.2Kb
Info (Gzip) - 3.4Mb
Info (Zip) - 3.4Mb
MySQL Globalization
MySQL Information Schema
MySQL Installation Guide
MySQL and Linux/Unix
MySQL and macOS
MySQL Partitioning
MySQL Performance Schema
MySQL Replication
Using the MySQL Yum Repository
MySQL Restrictions and Limitations
Security in MySQL
MySQL and Solaris
Building MySQL from Source
Starting and Stopping MySQL
MySQL Tutorial
MySQL and Windows
MySQL NDB Cluster 7.5