mysql事件執行預存程序,mysql事件預存程序
CREATE PROCEDURE InitializationData()BEGINupdate yt_products set number=number+100 where id=1;update yt_products set number=number+100 where id=2;update yt_products set number=number+100 where id=3;update yt_products set number=number+50 where id=4;update yt_products set number=number+1 where id=5;update yt_products set number=number+1 where id=6;update yt_products set number=number+1 where id=7;update yt_products set number=number+1 where id=8;update yt_products set number=number+10 where id=9;update yt_products set number=number+10 where id=10;update yt_products set number=number+10 where id=11;update yt_products set number=number+10 where id=12;update yt_products set number=number+5000 where id=13;update yt_products set number=number+6000 where id=14;END;
然後建立事件
CREATE EVENT `NewEvent`ON SCHEDULE EVERY 1 DAY STARTS '2015-04-01 17:49:10'ON COMPLETION NOT PRESERVEENABLEDOCALL InitializationData();
事件的意思是 從17:49:10 這個時間開始 每天 這個點執行這個事物