mysql 每個月創建新表
阿新 • • 發佈:2019-04-02
gin mysql form nth ner star rep into cut EXECUTE stmt1 ;
END
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 ;
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關閉定時任務
mysql 每個月創建新表