2013-08-23 32 views
5

Tôi đã tạo một số sự kiện. Nó đang chạy vào thời gian mà tôi đã tạo ra nó. Nhưng tôi muốn chạy các sự kiện khi bao giờ máy chủ mysql được bắt đầu. Ví dụ tôi đã tạo ra một sự kiện được gọi là mã CL_PL_CREDIT vẻ như,Lập lịch sự kiện khi khởi động mysql

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 ; 

Khi tôi gõ chương trình sự kiện nó được hiển thị như bắt đầu 2013/08/23 10:42:53, nhưng tôi muốn chạy nó trên mỗi Ngày đầu tiên của tháng khi máy chủ khởi động.

+0

Bạn có nghĩa là máy chủ khởi động lại mỗi ngày 1 của tháng và bạn muốn thực hiện sự kiện này bất cứ khi nào máy chủ khởi động lại, hoặc bạn muốn thực hiện sự kiện mỗi tháng 1 ngày? – RenkyaZ

Trả lời

1

Để thực hiện nó mỗi ngày 1 của tháng bạn nên thêm ngày bắt đầu:

ON SCHEDULE 
    EVERY 1 MONTH 
    STARTS AT '2013-09-01 00:00:00' 
Các vấn đề liên quan