MySQL code that allows a stored procedure to be timed to work

Source: Internet
Author: User

1. Build a database in MySQL test1

Statement: CREATE DATABASE Test1

2. CREATE TABLE Examinfo

CREATE TABLE Examinfo (
ID int auto_increment NOT NULL,
Endtime datetime,
Primary KEY (ID)
);

3 Inserting data:

INSERT into Examinfo values (' 1 ', ' 2011-4-23 23:26:50 ');

4 Creating a Stored procedure test

CREATE PROCEDURE Test ()
BEGIN
Update Examinfo SET endtime = Now () WHERE id = 1;
END;

5. Create Event E_test

Copy CodeThe code is as follows:

CREATE EVENT if not exists ev_realtime
On schedule every 1 day starts Date_add (date (curdate () + 1), Interval 1 hour)
On completion Preserve enable
Do call Pr_realtime_backup ();



6, check whether the event is open: Show variables like '%sche% ';
To open the event plan: set global event_scheduler=1;


Shutdown Event Task: Alter event e_test on completion PRESERVE DISABLE;
Account opening event task: Alter event e_test on completion PRESERVE ENABLE;

7, run the query results can appear the desired results.

Show events like '%ev_realtime% ';

MySQL code that allows a stored procedure to be timed to work

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.