# 创建分区表CREATETABLE`t_mr_ftp_file`(`id`INT(11)NOTNULLAUTO_INCREMENT,`sdate`INT(10)NOTNULL,`ip`VARCHAR(20)NULLDEFAULTNULL,`prod`VARCHAR(10)NULLDEFAULTNULL,`mrtype`VARCHAR(10)NULLDEFAULTNULL,`name`VARCHAR(256)NULLDEFAULTNULL,`size`BIGINT(20)NULLDEFAULTNULL,`create_time`TIMESTAMPNULLDEFAULTCURRENT_TIMESTAMPONUPDATECURRENT_TIMESTAMP,PRIMARYKEY(`id`,`sdate`)USINGBTREE)COLLATE='utf8mb4_unicode_ci'ENGINE=InnoDBPARTITIONBY RANGE (sdate)(PARTITION p2020081923 VALUES LESS THAN (2020082000)ENGINE=InnoDB);# 查看分区SELECT*FROM information_schema.partitions WHERE table_schema ='monitor'AND table_name ='t_mr_ftp_file';# 新增分区alterTABLE`t_mr_ftp_file`addPARTITION(PARTITION p2020082000 VALUES LESS THAN (2020082001)ENGINE=INNODB);alterTABLE`t_mr_ftp_file`addPARTITION(PARTITION p2020082001 VALUES LESS THAN (2020082002)ENGINE=INNODB);alterTABLE`t_mr_ftp_file`addPARTITION(PARTITION p2020082002 VALUES LESS THAN (2020082003)ENGINE=INNODB);alterTABLE`t_mr_ftp_file`addPARTITION(PARTITION p2020082003 VALUES LESS THAN (2020082004)ENGINE=INNODB);alterTABLE`t_mr_ftp_file`addPARTITION(PARTITION p2020082004 VALUES LESS THAN (2020082005)ENGINE=INNODB);alterTABLE`t_mr_ftp_file`addPARTITION(PARTITION p2020082005 VALUES LESS THAN (2020082006)ENGINE=INNODB);alterTABLE`t_mr_ftp_file`addPARTITION(PARTITION p2020082006 VALUES LESS THAN (2020082007)ENGINE=INNODB);alterTABLE`t_mr_ftp_file`addPARTITION(PARTITION p2020082007 VALUES LESS THAN (2020082008)ENGINE=INNODB);alterTABLE`t_mr_ftp_file`addPARTITION(PARTITION p2020082008 VALUES LESS THAN (2020082009)ENGINE=INNODB);alterTABLE`t_mr_ftp_file`addPARTITION(PARTITION p2020082009 VALUES LESS THAN (2020082010)ENGINE=INNODB);alterTABLE`t_mr_ftp_file`addPARTITION(PARTITION p2020082010 VALUES LESS THAN (2020082011)ENGINE=INNODB);alterTABLE`t_mr_ftp_file`addPARTITION(PARTITION p2020082011 VALUES LESS THAN (2020082012)ENGINE=INNODB);alterTABLE`t_mr_ftp_file`addPARTITION(PARTITION p2020082012 VALUES LESS THAN (2020082013)ENGINE=INNODB);alterTABLE`t_mr_ftp_file`addPARTITION(PARTITION p2020082013 VALUES LESS THAN (2020082014)ENGINE=INNODB);alterTABLE`t_mr_ftp_file`addPARTITION(PARTITION p2020082014 VALUES LESS THAN (2020082015)ENGINE=INNODB);alterTABLE`t_mr_ftp_file`addPARTITION(PARTITION p2020082015 VALUES LESS THAN (2020082016)ENGINE=INNODB);alterTABLE`t_mr_ftp_file`addPARTITION(PARTITION p2020082016 VALUES LESS THAN (2020082017)ENGINE=INNODB);alterTABLE`t_mr_ftp_file`addPARTITION(PARTITION p2020082017 VALUES LESS THAN (2020082018)ENGINE=INNODB);alterTABLE`t_mr_ftp_file`addPARTITION(PARTITION p2020082018 VALUES LESS THAN (2020082019)ENGINE=INNODB);alterTABLE`t_mr_ftp_file`addPARTITION(PARTITION p2020082019 VALUES LESS THAN (2020082020)ENGINE=INNODB);alterTABLE`t_mr_ftp_file`addPARTITION(PARTITION p2020082020 VALUES LESS THAN (2020082021)ENGINE=INNODB);alterTABLE`t_mr_ftp_file`addPARTITION(PARTITION p2020082021 VALUES LESS THAN (2020082022)ENGINE=INNODB);alterTABLE`t_mr_ftp_file`addPARTITION(PARTITION p2020082022 VALUES LESS THAN (2020082023)ENGINE=INNODB);alterTABLE`t_mr_ftp_file`addPARTITION(PARTITION p2020082023 VALUES LESS THAN (2020082100)ENGINE=INNODB);# 删除分区altertable`t_mr_ftp_file`dropPARTITION p2020081923;