mysql 创建定时器
来源:互联网 发布:linux查看jar文件内容 编辑:程序博客网 时间:2024/05/29 19:43
mysql定时器是系统给提供了event,而oracle里面的定时器是系统给提供的job。废话少说,下面创建表:
create table mytable (
id int auto_increment not null,
name varchar(100) not null default '',
introduce text not null,
createtime timestamp not null,
constraint pk_mytable primary key(id)
create procedure mypro()
BEGIN
insert into mytable (name,introduce,createtime) values ('1111','inner mongolia',now());
end;
紧接着创建mysql的定时器event:
create event if not exists eventJob
on schedule every 1 second
on completion PRESERVE
do call mypro();
这里设置为每一秒执行一次
至此所有的准备工作已经写完了,做完这些,mysql要想利用定时器必须的做准备工作,就是把mysql的定时器给开启了:
SET GLOBAL event_scheduler = 1; -- 启动定时器
SET GLOBAL event_scheduler = 0; -- 停止定时器
紧接着还要开启事件:
ALTER EVENT eventJob ON COMPLETION PRESERVE ENABLE; -- 开启事件
ALTER EVENT eventJob ON COMPLETION PRESERVE DISABLE; -- 关闭事件
create table mytable (
id int auto_increment not null,
name varchar(100) not null default '',
introduce text not null,
createtime timestamp not null,
constraint pk_mytable primary key(id)
)
create procedure mypro()
BEGIN
insert into mytable (name,introduce,createtime) values ('1111','inner mongolia',now());
end;
这里只是简单的写了一下,只是为了说明例子。
紧接着创建mysql的定时器event:
create event if not exists eventJob
on schedule every 1 second
on completion PRESERVE
do call mypro();
这里设置为每一秒执行一次
至此所有的准备工作已经写完了,做完这些,mysql要想利用定时器必须的做准备工作,就是把mysql的定时器给开启了:
SET GLOBAL event_scheduler = 1; -- 启动定时器
SET GLOBAL event_scheduler = 0; -- 停止定时器
紧接着还要开启事件:
ALTER EVENT eventJob ON COMPLETION PRESERVE ENABLE; -- 开启事件
ALTER EVENT eventJob ON COMPLETION PRESERVE DISABLE; -- 关闭事件
SHOW VARIABLES LIKE '%sche%'; -- 查看定时器状态
转载 http://www.blogjava.net/stevenjohn/archive/2015/02/06/389202.html#422788
0 0
- mysql 创建定时器
- mysql 创建定时器
- mysql 创建定时器
- mysql 创建定时器
- mysql 创建定时器
- mysql创建定时器(event)
- mysql创建定时器(event)
- mysql创建一个定时器创建日期表
- mysql创建定时器(event),查看定时器,打开定时器,设置定时器时间
- mysql创建定时器(event),查看定时器,打开定时器,设置定时器时间
- mysql创建定时器(event),查看定时器,打开定时器,设置定时器时间
- mysql创建定时器(event),查看定时器,打开定时器,设置定时器时间
- mysql创建定时器(event),查看定时器,打开定时器,设置定时器时间
- mysql创建定时器(event),查看定时器,打开定时器,设置定时器时间
- mysql创建定时器(event),查看定时器,打开定时器,设置定时器时间
- mysql创建定时器(event),查看定时器,打开定时器,设置定时器时间
- mysql创建定时器(event),查看定时器,打开定时器,设置定时器时间
- mysql创建定时器(每天凌晨执行)
- 清除eclipse中 Launch configuration的历史记录
- Android四大基本组件介绍与生命周期
- 16.Spring_使用JdbcTemplate
- 怎么把pdf格式的文章转换为ppt文件
- 0108 SpringMVC与Struts2的对比【基础】
- mysql 创建定时器
- Java使用-总结-1
- W: 无法下载 http://cn.archive.ubuntu.com/ubuntu/....校验和不符
- 使用intentService与service有什么不同呢
- 关于XML的读写操作以及查询操作
- 2014年总结
- 【开发日记】错误杂锦
- mysql 修改数据库密码
- iOS开发网络篇—文件下载(三·进度条)