SQL statement for MySQL to CREATE tables regularly -- view the event plan SELECT @ event_scheduler -- open the event plan www.2cto.com SET GLOBAL event_scheduler = 1 -- stored PROCEDURE, CREATE a table CREATE PROCEDURE create_table () every month () BEGIN declare str_date varchar (16); SET str_date = date_format (now (), "% Y % m"); SET @ sqlcmd1 = CONCAT ('create TABLE db_mail_message _ ', str_date, "(apptaskid varchar (100) not null, taskname varchar (200) not null, incluenduid varchar (200) not null, appreceiveuid varchar (100) not null, sendtime varchar (50) not null, handletime varchar (50) not null, url varchar (500) not null, remark varchar (500) not null, endtime varchar (50) not null, imapuid varchar (100) not null, addstatus int (1) not null default '0', readstatus int (1) not null default '0', deletestatus int (1) not null default '0 ', completestatus int (1) not null default '0', primary key (apptaskid), KEY db_imapuid_index (imapuid) ENGINE = MyISAM default charset = utf8 ;"); PREPARE p1 FROM @ sqlcmd1; EXECUTE p1; deallocate prepare p1; END -- create event: the stored procedure create event if not exists e_testON schedule every 1 secondon completion preservedo call test (); www.2cto.com -- creates an event every second: create event if not exists e_test on schedule every 1 month starts DATE_ADD (DATE_SUB (CURDATE (), interval day (CURDATE ()-1 DAY), INTERVAL 1 MONTH), INTERVAL 1 HOUR) on completion preserve do call test (); -- ENABLE event alter event e_test on completion preserve enable; -- DISABLE event alter event e_test on completion preserve disable;