1、
CREATE DEFINER=`root`@`%` PROCEDURE `aa`()
BEGIN
SET @sqlstr = CONCAT('create table cdrpbx10_',DATE_FORMAT(CURDATE(),'%Y%m'),' like cdrpbx10');
PREPARE stmt1 FROM @sqlstr ;
EXECUTE stmt1 ;
SET @sqlstr = CONCAT('insert into cdrpbx10_',DATE_FORMAT(CURDATE(),'%Y%m'),' select * from cdrpbx10');
PREPARE stmt1 FROM @sqlstr ;
EXECUTE stmt1 ;
END
2、
CREATE EVENT IF NOT EXISTS eventJob
#ON SCHEDULE EVERY 1 SECOND 每秒执行一次定时任务
ON SCHEDULE EVERY 1 MONTH STARTS '2019-04-01 11:08:53'
ON COMPLETION PRESERVE
DO CALL aa();
3、
SET GLOBAL event_scheduler = 1; 1开启定时任务 0关闭定时任务