mysql计划任务
这两天一直遇见mysql计划任务的案例,今天我就给大家分享一个真是的实例:
1、创建计划任务的语法:
create event 任务名称 on schedule at 时间周期 starts '年-月-日 时-分-秒‘ do sql语句
或者
create event 任务名称 on schedule every 时间周期 starts '年-月-日 时-分-秒‘ do sql语句
at 是在设置的时间中执行这条语句就不再执行了,而every 是一个循环的操作,比如我的时间设置的是'2015-05-08 17:55:00’,
at语句就是在这个2015-05-08 17:55:00时间点上执行,
而every 是在你设定的时间周期内重复执行这条语句。
2、查看计划任务执行状态:
def test e_test root@localhost SYSTEM SQL TRUNCATE TABLE a RECURRING 1 DAY STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION 2015-05-06 13:15:12 ENABLED NOT PRESERVE 2015-05-06 13:13:28 2015-05-06 13:13:28 2015-05-08 13:15:12 0 utf8 utf8_general_ci latin1_swedish_ci
def mysql e_test root@localhost SYSTEM SQL UPDATE users SET name=1300001 WHERE id=529 RECURRING 1 DAY STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION 2015-05-06 13:53:00 ENABLED NOT PRESERVE 2015-05-06 13:52:12 2015-05-06 13:52:12 2015-05-08 13:53:00 0 utf8 utf8_general_ci latin1_swedish_ci
def own e_test root@localhost SYSTEM SQL UPDATE emp SET city=4444444 WHERE id=8888 RECURRING 1 DAY STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION 2015-05-06 15:26:00 ENABLED NOT PRESERVE 2015-05-07 15:03:38 2015-05-07 15:03:38 2015-05-08 15:26:00 0 utf8 utf8_general_ci latin1_swedish_ci
def own e_update root@localhost SYSTEM SQL UPDATE user SET score=0 WHERE isvalid=1 RECURRING 1 DAY STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION 2015-05-06 15:00:00 ENABLED NOT PRESERVE 2015-05-07 15:03:38 2015-05-07 15:03:38 2015-05-08 15:00:00 0 utf8 utf8_general_ci latin1_swedish_ci
def mysql users_score_update root@localhost SYSTEM SQL UPDATE users as a LEFT JOIN (select user_id,sum(score) as score from scorerecords
where isvalid=1 and convert(createtime,date) = CURDATE()
and score >0 group by user_id) as b on a.id = b.user_id
set a.dailyscore = case when b.score is null then 0 else b.score end
where a.isvalid =1 RECURRING 1 DAY STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION 2015-05-06 15:00:00 ENABLED NOT PRESERVE 2015-05-07 12:01:43 2015-05-07 12:01:43 2015-05-08 15:00:00 0 utf8 utf8_general_ci latin1_swedish_ci
def ceshi w_update root@% SYSTEM SQL UPDATE wuceshi SET name ='ddd' WHERE id=1 RECURRING 1 DAY STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION 2015-05-08 14:03:00 ENABLED NOT PRESERVE 2015-05-08 14:02:56 2015-05-08 14:02:56 2015-05-08 14:03:00 0 utf8 utf8_general_ci latin1_swedish_ci
def damayi users_score_update root@% SYSTEM SQL UPDATE users as a LEFT JOIN (select user_id,sum(score) as score from scorerecords
where isvalid=1 and convert(createtime,date) = CURDATE()
and score >0 group by user_id) as b on a.id = b.user_id
set a.dailyscore = case when b.score is null then 0 else b.score end
where a.isvalid =1 RECURRING 1 DAY STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION 2015-05-08 15:26:00 ENABLED NOT PRESERVE 2015-05-08 15:24:52 2015-05-08 15:24:52 2015-05-08 15:26:00 0 utf8 utf8_general_ci latin1_swedish_ci
def damayi e_test_insert root@% SYSTEM SQL INSERT INTO test.aaa VALUES (CURRENT_TIMESTAMP) RECURRING 1 SECOND STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION 2015-05-08 15:04:17 ENABLED NOT PRESERVE 2015-05-08 15:04:17 2015-05-08 15:04:17 2015-05-08 18:02:40 0 utf8 utf8_general_ci latin1_swedish_ci
def mayidaxiangcs users_score_update root@% SYSTEM SQL UPDATE users as a LEFT JOIN (select user_id,sum(score) as score from scorerecords
where isvalid=1 and convert(createtime,date) = CURDATE()
and score >0 group by user_id) as b on a.id = b.user_id
set a.dailyscore = case when b.score is null then 0 else b.score end
where a.isvalid =1 RECURRING 1 DAY STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION 2015-05-06 00:00:00 ENABLED NOT PRESERVE 2015-05-08 15:47:21 2015-05-08 15:47:21 0 utf8 utf8_general_ci latin1_swedish_ci
def ceshievent users_score_update root@% SYSTEM SQL UPDATE users as a LEFT JOIN (select user_id,sum(score) as score from scorerecords
where isvalid=1 and convert(createtime,date) = CURDATE()
and score >0 group by user_id) as b on a.id = b.user_id
set a.dailyscore = case when b.score is null then 0 else b.score end
where a.isvalid =1 RECURRING 1 DAY STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION 2015-05-06 00:00:00 ENABLED NOT PRESERVE 2015-05-08 16:57:36 2015-05-08 16:57:36 0 utf8 utf8_general_ci latin1_swedish_ci
def damayidaxiang users_score_update root@% SYSTEM SQL UPDATE users as a LEFT JOIN (select user_id,sum(score) as score from scorerecords
where isvalid=1 and convert(createtime,date) = CURDATE()
and score >0 group by user_id) as b on a.id = b.user_id
set a.dailyscore = case when b.score is null then 0 else b.score end
where a.isvalid =1 RECURRING 5 MINUTE STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION 2015-05-08 17:55:00 ENABLED NOT PRESERVE 2015-05-08 17:56:21 2015-05-08 17:56:21 2015-05-08 18:00:00 0 utf8 utf8_general_ci latin1_swedish_ci
mysql计划任务的更多相关文章
- 如何开启mysql计划事件
如何开启mysql计划事件 (2012-07-26 12:21:23) 转载▼ 标签: mysql 事件计划 it 分类: MySQL 首先在sql中查询计划事件的状态:SHOW VARIABLES ...
- 创建和使用MySQL计划事件
查看事件调度程序线程的状态: SHOW PROCESSLIST; 要启用和启动事件调度程序线程命令: SET GLOBAL event_scheduler = ON; 禁用和停止事件调度程序线程: S ...
- mysql计划字段中有多少个逗号,或者某个标识符
eg:计划url中有多少个小数点 select length('www.mysql.com')-length(REPLACE('www.mysql.com','.',''));
- mysql计划任务每天定时执行
代码例子:CREATE EVENT `course_listener` ON SCHEDULE EVERY DAY STARTS '2012-07-18 00:00:00' ON COMPLETION ...
- MySQL计划任务(事件调度器)(Event Scheduler)
http://www.cnblogs.com/c840136/articles/2388512.html https://dev.mysql.com/doc/refman/5.7/en/events- ...
- MySQL计划任务(事件调度器)(Event Scheduler)[转]
原文链接: http://www.cnblogs.com/c840136/articles/2388512.html MySQL5.1.x版本中引入了一项新特性EVENT,顾名思义就是事件.定时任务机 ...
- Mysql 计划任务
-- 设置 show variables like '%sche%'; ; -- Start存储过程 drop PROCEDURE if exists test; CREATE PROCEDURE t ...
- 【转】mysql 计划事件
转自:http://www.cnblogs.com/c840136/articles/2388512.html MySQL5.1.x版本中引入了一项新特性EVENT,顾名思义就是事件.定时任务机制,在 ...
- MySQL计划任务(事件调度器)
原文:http://www.cnblogs.com/c840136/articles/2388512.html 备忘; MySQL5.1.x版本中引入了一项新特性EVENT,顾名思义就是事件.定时任务 ...
随机推荐
- mac工具-解析json visualJSON和JSON Accelerator这两款工具
- 封装,策略模式,Asp换脸
1.简单封装 1>计算类 using System; using System.Collections.Generic; using System.Linq; using System.Text ...
- python2.7使用ansible
升级python到2.7后 $ ansible 报错 Traceback (most recent call last): File "/usr/bin/ansible", lin ...
- logstash5.x改变
5.x版本 logstash中 elasticsearch插件的workers,无法配置大于1,会提示 This plugin uses the shared and doesn't need thi ...
- scan design flow(二)
在scan stitch之后,scan synthesis就已经完成, Scan extraction主要用来从scan design中extracing所有的instance,来保证scan cha ...
- (第九周)视频发布及git统计报告
项目名:食物链教学工具 组名:奋斗吧兄弟 组长:黄兴 组员:李俞寰.杜桥.栾骄阳.王东涵 代码地址:HTTPS: https://git.coding.net/li_yuhuan/FoodChain. ...
- php+jquery注册实例
写了一个简单的PHP+jQuery注册模块,需要填写的栏目包括用户名.邮箱.密码.重复密码和验证码,其中每个栏目需要具备的功能和要求如下图: 在做这个模块的时候,很大程度上借鉴了网易注册( http: ...
- 各种类型的Writable(Text、ByteWritable、NullWritable、ObjectWritable、GenericWritable、ArrayWritable、MapWritable、SortedMapWritable)转
java原生类型 除char类型以外,所有的原生类型都有对应的Writable类,并且通过get和set方法可以他们的值. IntWritable和LongWritable还有对应的变长VIntWri ...
- android 项目学习随笔二十一(IM、语音识别、机器人、统计、扫描二维码、条形码)
语音识别:科大讯飞语音云 http://www.xfyun.cn/ 语音机器人模拟 public class TalkBean { public String text; public boolean ...
- android 学习随笔一(配置调试与基础)
一.基础与开发环境安装配置 Memory Options: VM Heap表示每个应用所能占用的最大内存. Android 项目目录结构 SRC java源码 android.jar 导入jar才能使 ...