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 the Code code as follows:
CREATE EVENT if not exists e_test
On schedule every second
On completion Preserve
Do call Test ();
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.
The results are shown below:
Raw data:
After a period of time query data:
MySQL code for a stored procedure timed job (GO)