• Mysql计划任务


    1、检查计划任务是否开启
    mysql> set global event_scheduler=off;
    Query OK, 0 rows affected
    mysql> select @@event_scheduler;
    +-------------------+
    | @@event_scheduler |
    +-------------------+
    | OFF               |
    +-------------------+
    1 row in set
    mysql> set global event_scheduler=on;
    Query OK, 0 rows affected
    mysql> select @@event_scheduler;
    +-------------------+
    | @@event_scheduler |
    +-------------------+
    | ON                |
    +-------------------+
    1 row in set
    2、创建计划任务
    mysql> show events;
    Empty set
    mysql> create event event_insert on schedule every 1 second enable do insert into stu (name,age,updatetime) values('Caroline',5,now());
    Query OK, 0 rows affected
    mysql> show events;
    +--------+--------------+---------+-----------+-----------+------------+----------------+----------------+---------------------+------+---------+------------+----------------------+----------------------+--------------------+
    | Db     | Name         | Definer | Time zone | Type      | Execute at | Interval value | Interval field | Starts              | Ends | Status  | Originator | character_set_client | collation_connection | Database Collation |
    +--------+--------------+---------+-----------+-----------+------------+----------------+----------------+---------------------+------+---------+------------+----------------------+----------------------+--------------------+
    | testdb | event_insert | root@%  | SYSTEM    | RECURRING | NULL       | 1              | SECOND         | 2015-03-25 19:57:41 | NULL | ENABLED |          0 | utf8                 | utf8_general_ci      | utf8_general_ci    |
    +--------+--------------+---------+-----------+-----------+------------+----------------+----------------+---------------------+------+---------+------------+----------------------+----------------------+--------------------+
    1 row in set
    3、定时添加记录
    mysql> delete from stu;
    Query OK, 6 rows affected
    mysql> select * from stu;
    +-----+----------+-----+---------------------+
    | Id  | Name     | Age | updatetime          |
    +-----+----------+-----+---------------------+
    | 232 | Caroline |   5 | 2015-03-25 19:58:57 |
    | 233 | Caroline |   5 | 2015-03-25 19:58:58 |
    +-----+----------+-----+---------------------+
    2 rows in set
    4、修改计划任务
    mysql> alter event event_insert on schedule every 1 second disable;
    Query OK, 0 rows affected
  • 相关阅读:
    【idea-部署web项目】
    【IDEA下使用tomcat部署web项目】
    【 PLSQL Developer安装、tnsnames.ora配置 解答】
    【idea--git】
    【Sping管理bean的原理】
    【关于eclipse的一些自己常用的插件】
    【Spring-任务调度】
    【mysql存储引擎】
    【mysql-索引+存储过程+函数+触发器-更新。。。】
    【转-mysql-explain介绍】
  • 原文地址:https://www.cnblogs.com/nzbbody/p/4391793.html
Copyright © 2020-2023  润新知