1 CREATE TABLE part_tab 2 ( c1 int default NULL, 3 c2 varchar(30) default NULL, 4 c3 date default NULL 5 ) engine=myisam 6 PARTITION BY RANGE (year(c3)) 7 ( 8 PARTITION p0 VALUES LESS THAN (1995), 9 PARTITION p1 VALUES LESS THAN (1996) , 10 PARTITION p2 VALUES LESS THAN (1997) ,11 PARTITION p3 VALUES LESS THAN (1998) ,12 PARTITION p4 VALUES LESS THAN (1999),13 PARTITION p5 VALUES LESS THAN (2000) , 14 PARTITION p6 VALUES LESS THAN (2001) ,15 PARTITION p7 VALUES LESS THAN (2002) , 16 PARTITION p8 VALUES LESS THAN (2003) ,17 PARTITION p9 VALUES LESS THAN (2004) , 18 PARTITION p10 VALUES LESS THAN (2010),19 PARTITION p11 VALUES LESS THAN MAXVALUE 20 );21 22 23 create table no_part_tab24 (c1 int(11) default NULL,25 c2 varchar(30) default NULL,26 c3 date default NULL27 ) engine=myisam;28 29 30 delimiter //31 CREATE PROCEDURE load_part_tab()32 begin33 declare v int default 0;34 while v < 800000035 do36 insert into part_tab(c1,c2,c3)37 values (v,'testing partitions',adddate('1995-01-01',(rand(v)*36520) mod 3652));38 set v = v + 1;39 end while;40 end41 //42 43 delimiter ;44 call load_part_tab();45 explain select count(*) from no_part_tab where46 c3 > date '1995-01-01' and c3 < date '1995-12-31';47 48 explain select count(*) from part_tab where49 c3 > date '1995-01-01' and c3 < date '1995-12-31';50 51 52 53 54 CREATE TABLE part_tab255 ( 56 c1 int default NULL57 ) engine=myisam58 PARTITION BY RANGE (c1) 59 (60 PARTITION p0 VALUES LESS THAN (5),61 PARTITION p1 VALUES LESS THAN (10),62 PARTITION p2 VALUES LESS THAN MAXVALUE63 );64 65 insert into part_tab2 values(2),(3);