利用mysql事件定时自动执行
BEGIN
set @table_name = concat('p', DATE_FORMAT(DATE_ADD(NOW(),INTERVAL 1 DAY),'%Y%m%d'));
set @max_value = DATE_FORMAT(DATE_ADD(NOW(),INTERVAL 1 DAY),'%Y%m%d');
set @excutesql = CONCAT('ALTER TABLE 表名 ADD PARTITION (PARTITION ',@table_name,' VALUES LESS THAN ("',@max_value,'"))');
SELECT @excutesql;
PREPARE stmt from @excutesql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END