MySQL Create timer

Source: Internet
Author: User

 mysql timer is the system to provide an event, and the timer inside Oracle is the system to provide the job. Less nonsense, create table below: Creation table mytable (id int auto_increment not null,name varchar (+) NOT NULL default ", introduce text not n Ull,createtime Timestamp not null,constraint pk_mytable primary key (ID)) Creates a stored procedure, Here the stored procedure is mainly provided to the MySQL timer event to invoke to execute: CREATE PROCEDURE Mypro () Begininsert into MyTable (name,introduce,createtime) values (' 1111 ', ' Inner Mongolia ', now ()); end; Here is just a simple write-up, just to illustrate the example. Immediately after creating the MySQL timer Event:create event if not exists eventjob on schedule every 1 second on completion Preservedo call Mypro ();  is set to execute once every second. All the preparation work has been finished, and to do this, MySQL to use the timer must be ready to work, is to turn on the MySQL timer: set GLOBAL Event_scheduler = 1;  --Start timer set GLOBAL Event_scheduler = 0;   --The Stop timer is followed by the event: ALTER event eventjob on completion PRESERVE ENABLE;  --Open event alter event eventjob on completion PRESERVE DISABLE; --Close event show VARIABLES like '%sche% '; --Check the timer status at this point, you go to the database inside the table mytable inside to see, the system will be every second to insert a data, hehe, the task is completed. SELECT * FROM MyTable  

MySQL Create timer

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.