Mysql – Where is the old partition in thesql show create table

MySQLpartitioning

I am keep adding daily base partition for a table as e.g.

ALTER TABLE tblData PARTITION BY RANGE (to_days(`dataInsertDateTime`)) (
PARTITION p20 VALUES LESS THAN (to_days('2012-12-25')),
PARTITION p21 VALUES LESS THAN (to_days('2012-12-26')),
PARTITION p22 VALUES LESS THAN (to_days('2012-12-27')),
PARTITION p23 VALUES LESS THAN (to_days('2012-12-28')),
PARTITION p24 VALUES LESS THAN (to_days('2012-12-29'))
)

When I run this show create table tblData is only shows me the partition p20 to p24. I am wondering where is all my previous p0-p19? Is it get dissolve when each time I run the alter table to add partitions?

Best Answer

You don't have plessthanmax part? When you set up a partition (that "moves" daily) the best practice is to set up a plessthanmax part to avoid errors. Each day you create a new partition and reorganise the plessthanmax like this :

For December 29

ALTER TABLE BtblData REORGANIZE PARTITION plessthanmax INTO (PARTITION p24 VALUES LESS THAN (to_days('2012-12-29')), partition plessthanmax values less than maxvalue)

For December 30

ALTER TABLE BtblData REORGANIZE PARTITION plessthanmax INTO (PARTITION p25 VALUES LESS THAN (to_days('2012-12-30')), partition plessthanmax values less than maxvalue)

Max.