5

我创建了一些事件。它在我创建它的时间运行。但是我想在启动 mysql 服务器时运行该事件。例如,我创建了一个名为 CL_PL_CREDIT 的事件,代码看起来像,

delimiter |

CREATE EVENT RURALSHORES2.UpLv
    ON SCHEDULE
      EVERY 1 MONTH
    DO
      BEGIN
      update emp_lv_rem set cl_count=cl_count+1,pl_count=pl_count+1.25 where emp_id in (select emp_id from emp_main where EmploymentType="Permanent" or EmploymentType="Regular");
      update emp_lv_rem set cl_count=1,pl_count=1 where emp_id in (select emp_id from emp_main where EmploymentType="Probation");
      update emp_lv_rem set cl_count=1,pl_count=0 where emp_id in (select emp_id from emp_main where EmploymentType="Contract" or EmploymentType="Partime" or EmploymentType="Trainee" or EmploymentType="Consultant");
update emp_lv_rem set cl_count=0,pl_count=0 where emp_id in (select emp_id from emp_main where EmploymentType="Contract" and EmploymentType<>"Partime" and EmploymentType<>"Trainee" and EmploymentType<>"Consultant" and EmploymentType="Permanent" and EmploymentType="Regular" and EmploymentType="Probation");

    END |;

delimiter ;

当我输入显示事件时,它显示为从 2013 年 8 月 23 日 10:42:53 开始,但我想在服务器启动时的每个月的第一天运行它。

4

1 回答 1

1

为了在每月的第一天执行它,您应该添加开始日期:

ON SCHEDULE
  EVERY 1 MONTH
  STARTS AT '2013-09-01 00:00:00'
于 2013-08-26T15:13:49.090 回答