zoukankan      html  css  js  c++  java
  • 数据插入不覆盖更新,设置定时任务

    数据插入不覆盖更新
    INSERT INTO user_role(
    user_id,
    role_id,
    type,
    is_del
    )SELECT
    zgh as user_id,
    126 as role_id,
    2 as type,
    0 as is_del
    FROM sugon_jzg_jbxx b
    where not exists (select 1 from user_role a where a.user_id=b.zgh)
     
    查看event是否开启
    show variables like '%sche%';
     
    将事件计划开启
    set global event_scheduler=1;
     
    创建存储过程add_user_role
    CREATE PROCEDURE add_user_role()
    BEGIN
    INSERT INTO user_role(
    user_id,
    role_id,
    type,
    is_del
    )SELECT
    zgh as user_id,
    126 as role_id,
    2 as type,
    0 as is_del
    FROM sugon_jzg_jbxx b
    where not exists (select 1 from user_role a where a.user_id=b.zgh);
    END;
     
    每天定时执行任务,设置第一次执行时间为'2018-11-15 03:00:00',并且每天执行一次
    create event if not exists e_add_user_role
    on schedule every 1 day starts '2018-11-15 03:00:00'
    do call add_user_role();
     
    查询任务
    select * from mysql.event
     
    关闭事件任务
    alter event e_add_user_role ON COMPLETION PRESERVE DISABLE;
     
    开启事件任务
    alter event e_add_user_role ON COMPLETION PRESERVE ENABLE;
     
    删除任务计划
    drop event if exists e_add_user_role;
     
     
  • 相关阅读:
    所写既所思
    OO总结
    OO第三单元作业总结
    OO第二单元作业总结
    OO第一单元作业总结
    oo第四单元与课程总结
    oo第三单元总结——jml
    oo第二单元博客总结
    面向对象设计与构造-第一单元作业总结
    个人总结-不说再见
  • 原文地址:https://www.cnblogs.com/liquan-anran/p/9957293.html
Copyright © 2011-2022 走看看