mysql 创建定时 存储

//创建定时
create event if not exists tt_dingshi
on schedule every 1 day 具体时间 at timestamp '2011-04-12 03:00:00' 或者 starts '2011-04-12 03:00:00' ends '2099-04-12 03:00:00'
on completion preserve 这个是执行一次还是持续执行 not
do call XXXXXtj();

//创建存储
delimiter //
create procedure XXXXXtj()
begin
//具体某一段时间
insert into t_1101(contentid,ip,clicktime)select contentid,ip,clicktime from t_1012 where clicktime> unix_timestamp('2010-12-01') and clicktime<unix_timestamp('2010-12-02');
//前一天
insert into t_1101(contentid,ip,clicktime)select contentid,ip,clicktime from t_1012 where clicktime> unix_timestamp(current_date-1) and clicktime<unix_timestamp(current_date);
end;
//
delimiter ;

你可能感兴趣的:(mysql,数据库,职场,休闲,定时存储)