欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

mysql 讓一個存儲過程定時作業(yè)的代碼

 更新時間:2011年05月07日 23:41:20   作者:  
以下例子主要是實現(xiàn)簡單的mysq 定時作業(yè),需要的朋友可以參考下。
1、在mysql 中建立一個數(shù)據(jù)庫 test1

語句:create database test1

2、創(chuàng)建表examinfo

create table examinfo(
id int auto_increment not null,
endtime datetime,
primary key(id)
);

3 插入數(shù)據(jù):

insert into examinfo values('1','2011-4-23 23:26:50');

4 創(chuàng)建存儲過程test

CREATE PROCEDURE test ()
BEGIN
update examinfo SET endtime = now() WHERE id = 1;
END;

5、 創(chuàng)建event e_test
復(fù)制代碼 代碼如下:

CREATE EVENT if not exists e_test
on schedule every 30 second
on completion preserve
do call test();


6、查看event是否開啟: show variables like '%sche%';
將事件計劃開啟: set global event_scheduler=1;
關(guān)閉事件任務(wù): alter event e_test ON COMPLETION PRESERVE DISABLE;
開戶事件任務(wù): alter event e_test ON COMPLETION PRESERVE ENABLE;

7、運行查詢結(jié)果即可出現(xiàn)想要的結(jié)果。

結(jié)果顯示如下:
 原始數(shù)據(jù):

過一段時間查詢后的數(shù)據(jù):
 

相關(guān)文章

最新評論