ascending order. Only column names are permitted as sort criteria; arbitrary expressions are not permitted. This clause should be given last after any other clauses. 

ORDER BY  does not make sense for InnoDB  tables because InnoDB  always orders table rows according to the clustered index. 

When used on a partitioned table, ALTER TABLE ... ORDER BY  orders rows within each partition only. 

## Partitioning Options 

partition_options  signifies options that can be used with partitioned tables for repartitioning, to add, drop, discard, import, merge, and split partitions, and to perform partitioning maintenance. 

It is possible for an ALTER TABLE  statement to contain a PARTITION BY  or REMOVE PARTITIONING clause in an addition to other alter specifications, but the PARTITION BY  or REMOVE PARTITIONING clause must be specified last after any other specifications. The ADD PARTITION , DROP PARTITION , DISCARD PARTITION , IMPORT PARTITION , COALESCE PARTITION , REORGANIZE PARTITION , EXCHANGE PARTITION , ANALYZE PARTITION , CHECK PARTITION , and REPAIR PARTITION  options cannot be combined with other alter specifications in a single ALTER TABLE , since the options just listed act on individual partitions. 

For more information about partition options, see Section 13.1.20, “CREATE TABLE Statement” , and Section 13.1.9.1, “ALTER TABLE Partition Operations” . For information about and examples of ALTER TABLE ... EXCHANGE PARTITION  statements, see Section 24.3.3, “Exchanging Partitions and Subpartitions with Tables” . 

## 13.1.9.1 ALTER TABLE Partition Operations 

Partitioning-related clauses for ALTER TABLE  can be used with partitioned tables for repartitioning, to add, drop, discard, import, merge, and split partitions, and to perform partitioning maintenance. 

•Simply using a partition_options  clause with ALTER TABLE  on a partitioned table repartitions the table according to the partitioning scheme defined by the partition_options . This clause always begins with PARTITION BY , and follows the same syntax and other rules as apply to the partition_options  clause for CREATE TABLE  (for more detailed information, see Section 13.1.20, “CREATE TABLE Statement” ), and can also be used to partition an existing table that is not already partitioned. For example, consider a (nonpartitioned) table defined as shown here: 

CREATE TABLE t1 ( id INT, year_col INT ); 

This table can be partitioned by HASH , using the id  column as the partitioning key, into 8 partitions by means of this statement: 

ALTER TABLE t1 PARTITION BY HASH(id) PARTITIONS 8; 

MySQL supports an ALGORITHM  option with [SUB]PARTITION BY [LINEAR] KEY . ALGORITHM=1 causes the server to use the same key-hashing functions as MySQL 5.1 when computing the placement of rows in partitions; ALGORITHM=2  means that the server employs the key-hashing functions implemented and used by default for new KEY  partitioned tables in MySQL 5.5 and later. (Partitioned tables created with the key-hashing functions employed in MySQL 5.5 and later cannot be used by a MySQL 5.1 server.) Not specifying the option has the same effect as using ALGORITHM=2 . This option is intended for use chiefly when upgrading or downgrading [LINEAR] KEY  partitioned tables between 

