MySQL timer enabling and calling

Source: Internet
Author: User

MySQL timer is enabled and call to CREATE test TABLE www.2cto.com 1 create table t2 (3 v VARCHAR (100) NOT NULL4) engine innodb default charset = utf8; CREATE a timer to call the Stored PROCEDURE 1 DELIMITER $2 drop procedure if exists e_test $3 create procedure e_test () 4 BEGIN5 insert into t VALUES ('1 '); 6 END $7 DELIMITER; the constant GLOBAL event_scheduler for timing MySQL must be on or 1 -- check whether the timer 1 show variables like '% sche %' is enabled '; -- enable the timer 0: off 1: on 1 set global event_scheduler = 1; -- creates an event -- automatically calls e_test () every second () stored Procedure 1 create event if not exists event_test2ON schedule every 1 SECOND3ON completion preserve 4DO CALL e_test (); -- enable event 1 alter event event_test ON 2 completion preserve enable; -- disable event 1 alter event event_test ON 2 completion preserve disable; from now on, execute 1 create event EVENT1 2ON schedule every 9 day starts now () 3ON completion preserve enable 4DO5 BEGIN 6 call total (); 7. Run 1 create event EVENT2 2ON schedule every 1 month starts DATE_ADD (DATE_SUB (CURDATE (), interval day (CURDATE () at each MONTH at END 1 ()) -1 DAY), INTERVAL 1 MONTH), INTERVAL 1 HOUR) 3ON completion preserve enable 4DO 5 BEGIN 6 call stat (); 7 END: 1 create event TOTAL_SEASON_EVENT 2ON schedule every 1 quarter starts DATE_ADD (DATE (CONCAT (YEAR (CURDATE ()),'-', ELT (QUARTER (CURDATE (),), '-', 1), INTERVAL 1 QUARTER), INTERVAL 2 HOUR) 3ON completion preserve enable 4DO 5 BEGIN 6 CALL SEASON_STAT (); 7 END: Execute 1 create event TOTAL_YEAR_EVENT 2ON schedule every 1 year starts DATE_ADD (DATE (CONCAT (YEAR (CURDATE () + 1, '-', 1, '-', 1), INTERVAL 4 HOUR) 3ON completion preserve enable 4DO 5 BEGIN 6 CALL YEAR_STAT (); 7 END MySQL events are performed by month, quarter, for testing, you can change the system to the last day of the year, for example, 23:59:55;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.