MySQL Event events

Source: Internet
Author: User

First, the keyword: event two, Syntax: CREATE event? [If not EXISTS]//Create event_name if not present? On SCHEDULE schedle[on completion [NOT] preserve][enable| Desable][comment ' COMMENT ']dosql_statementDescription: The name of the 1.event_name event 2.ON schedule has two ways of setting up Scheduled tasks: #单次计划任务: The number of time (units) at time stamp #重复的计划任务EVERY time unit [starts timestamp][ends timestamp] In both scheduled tasks, The timestamp can be any of the TIMESTAMP and datetime data types, requiring a future time (greater than current_timestamp), and less than the last time of the Unix time (equal to or less than ' 2037-12-31 23:59:59 ') The time unit is the keyword: Year,month,day,hour,minute or second 3. [on completion [NOT] PRESERVE] Completion when a single scheduled task is completed or when a recurring scheduled task is executed to the ends stage. The function of declaring preserve is that the event is not dropped by 4 after the execution is complete. [enable| Desable]enable Open Event desable Shutdown Event 5.COMMENT Comment 6.DOsql_statementPerformed bySQL statementsThirdly, we can dynamically control whether the event scheduler is enabled by setting the value of the global variable Event_scheduler. See if Event_scheduler opens mysql> SHOW VARIABLES like '%event% '; Set to openmysql> SET GLOBAL event_scheduler=on;Iv. Example: Insert a log per minute: DELIMITER//create EVENT ' user_log_event ' on SCHEDULE every 1 MINUTE starts ' 2010-12-27 00:00:00 '? On completion not PRESERVE ENABLE do? BEGIN? INSERT into log SET addtime=now (); end//CallStored procedures:DELIMITER//create EVENT ' user_log_event ' on SCHEDULE every 1 day starts ' 2010-00-00 00:00:00 '? On completion not PRESERVE ENABLE do? Begincall User_log_prov (); end//

MySQL Event events

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.