mysql 让一个存储过程定时作业的代码
时间:2024-01-26 18:35:28
1、在mysql 中建立一个数据库 test1
语句:create database test1
2、创建表examinfo
create table examinfo(
id int auto_increment not null,
endtime datetime,
primary key(id)
);
3 插入数据:
insert into examinfo values('1','2011-4-23 23:26:50');
4 创建存储过程test
CREATE PROCEDURE test ()
BEGIN
update examinfo SET endtime = now() WHERE id = 1;
END;
5、 创建event e_test
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;
关闭事件任务: alter event e_test ON COMPLETION PRESERVE DISABLE;
开户事件任务: alter event e_test ON COMPLETION PRESERVE ENABLE;
7、运行查询结果即可出现想要的结果。
结果显示如下:
原始数据:
过一段时间查询后的数据:
标签:mysql,存储过程
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python处理csv数据的方法
2023-03-08 19:05:31
Python的函数使用详解
2021-11-22 15:34:25
![](https://img.aspxhome.com/file/2023/5/85335_0s.png)
聊聊Druid register mbean error的问题
2022-09-15 19:09:00
![](https://img.aspxhome.com/file/2023/6/131816_0s.png)
python爬虫 批量下载zabbix文档代码实例
2022-11-07 11:10:29
python3 pygame实现接小球游戏
2023-07-28 18:04:21
![](https://img.aspxhome.com/file/2023/3/98863_0s.png)
mysql data文件夹位置查找
2024-01-15 08:20:38
Python实现自动登录百度空间的方法
2023-11-11 09:11:23
正视WEB标准,一本全面的标准参考书
2009-05-30 16:36:00
![](https://img.aspxhome.com/file/UploadPic/20095/30/s3396721-91s.jpg)
Python使用read_csv读数据遇到分隔符问题的2种解决方式
2022-01-13 13:30:47
![](https://img.aspxhome.com/file/2023/7/103507_0s.png)
pandas中对文本类型数据的处理小结
2022-06-25 06:39:16
![](https://img.aspxhome.com/file/2023/7/70787_0s.png)
操作mysql数据库的类
2010-03-13 12:53:00
python中@property和property函数常见使用方法示例
2021-11-13 03:32:20
Golang中的参数传递示例详解
2024-05-08 10:51:33
![](https://img.aspxhome.com/file/2023/8/127368_0s.png)
如何过滤中国站长站(chianz)文章干扰码
2008-01-04 20:14:00
![](https://img.aspxhome.com/file/UploadPic/up/2008010420592338.gif)
使用Python实现图像融合及加法运算
2021-03-03 06:19:42
![](https://img.aspxhome.com/file/2023/7/128767_0s.jpg)
DW表格应用之细线框的制作
2008-02-03 19:00:00
![](https://img.aspxhome.com/file/UploadPic/20082/3/20082319946365s.gif)
oracle的一些tips技巧
2009-03-02 11:06:00
Python读取Excel表格,并同时画折线图和柱状图的方法
2023-12-25 07:11:27
![](https://img.aspxhome.com/file/2023/5/117305_0s.jpg)
Python远程控制Windows服务器的方法详解
2023-07-13 13:14:03
![](https://img.aspxhome.com/file/2023/9/61169_0s.jpg)
python起点网月票榜字体反爬案例
2021-03-11 02:56:05
![](https://img.aspxhome.com/file/2023/1/93441_0s.jpg)