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,顾名思义就是事件.定时任务 ...
随机推荐
- String[] 转List<String>
String[] 转List<String> String[] idArr = ids.split(","); List<String> idList = ...
- Java中的数组操作进阶
package com.mi.array; import java.util.Arrays; /** * System.arraycopy(i, 0, j, 0, i.length);这种复制会覆盖目 ...
- java 网络编程(三)---TCP的基础级示例
下面是TCP java网络编程的基础示例: tcp传输:客户端建立过程的思路:1.创建TCP客户端的Socket服务,使用的是socket对象,建议在创建的过程中,就明确了目的地和要连接的主机2.如果 ...
- yii2多语言设置
yii2的多语言切换功能 1.页面添加语言切换按钮,如下图: 代码如下: <ul> <li> <a href="javascri ...
- fix org.openqa.selenium.NoSuchWindowException when find element on ie11.
Steps:1.I was able to resolve the issue after adding the site URL under trusted sites of IE. The sam ...
- plsql 简单介绍
plsql的安装: 1. 安装plsql developer 2. 下载,解压instantclient到任意目录 3. 在instantclient解压目录下,新建NETWORK目录,在该目录下建A ...
- VMware中安装CentOS7网络配置静态IP地址,常用配置和工具安装
VMware中安装CentOS7网络配置静态IP地址,常用配置和工具安装在阿里云开源镜像地址下载镜像Index of /centos/7.2.1511/isos/x86_64/http://mirro ...
- Delphi中CoInitialize之探究
CoInitialize(LPVOID),它将以特定参数调用CoInitializeEx,为当前单元初始化COM库,并标记协同模式为单线程模式.参数必须为NULL.这是关于OLE和COM的问题. Co ...
- 【jqGrid for ASP.NET MVC Documentation】.学习笔记.7.搜索过滤数据
1 基础 搜索和过滤功能,是使用确定的条件,查找匹配行数据.jqGrid提供几种搜索模式: Search Dialog 单搜索选项 Search Dialog 多搜索选项 ToolBar Search ...
- Linux下后台程序完成自动输入密码等交互行为的例子
今天要开发一个定时任务,然后加入cron列表中.但是有个问题摆在眼前,脚本的执行中需要输入数据库密码: mysql -u root -p << SQL use db; set names ...