mysql按日期分区测试

库结构:

CREATE TABLE part_date3  
    (  c1 INT DEFAULT NULL,  
      c2 VARCHAR(30) DEFAULT NULL,  
      c3 DATETIME DEFAULT NULL) ENGINE=MYISAM  
          PARTITION BY RANGE (TO_DAYS(c3))  
     (PARTITION p0 VALUES LESS THAN (TO_DAYS('1995-01-01')),  
     PARTITION p1 VALUES LESS THAN (TO_DAYS('1996-01-01')) ,  
     PARTITION p2 VALUES LESS THAN (TO_DAYS('1997-01-01')) ,  
     PARTITION p3 VALUES LESS THAN (TO_DAYS('1998-01-01')) ,  
     PARTITION p4 VALUES LESS THAN (TO_DAYS('1999-01-01')) ,  
     PARTITION p5 VALUES LESS THAN (TO_DAYS('2000-01-01')) ,  
     PARTITION p6 VALUES LESS THAN (TO_DAYS('2001-01-01')) ,  
     PARTITION p7 VALUES LESS THAN (TO_DAYS('2002-01-01')) ,  
     PARTITION p8 VALUES LESS THAN (TO_DAYS('2003-01-01')) ,  
     PARTITION p9 VALUES LESS THAN (TO_DAYS('2004-01-01')) ,  
     PARTITION p10 VALUES LESS THAN (TO_DAYS('2010-01-01')),  
     PARTITION p11 VALUES LESS THAN MAXVALUE );  

查看计划:


EXPLAIN PARTITIONS  SELECT * FROM part_date3 WHERE c3> DATE('1995-03-01') AND c3 

结构:

     

     
     
     
     
     
     

你可能感兴趣的:(数据库)