我创造了一些活动。它在我创建它的时间运行。但我希望在启动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 ;
当我输入show events时,它显示为2013-08-23 10:42:53的开始,但是我想在服务器启动的每个第一天运行它。
答案 0 :(得分:1)
为了每月的第一天执行它,您应该添加开始日期:
ON SCHEDULE
EVERY 1 MONTH
STARTS AT '2013-09-01 00:00:00'