General traffic is larger than the Web site, and the request log table is created independently of one table per day. The business needs to add a new column for each table, and for half a day, write a stored procedure like this:
Log table structure type tbl_ads_req_20140801, tbl_ads_req_20140802 ...
DELIMITER//
CREATE PROCEDURE SP2 ()
Begin
DECLARE stime varchar (32);
DECLARE etime varchar (32);
DECLARE sName varchar (128);
DECLARE lName varchar (128);
DECLARE Sqlvar varchar (128);
declare rest int;
Set stime = ' 20140801 ';
Set etime = ' 20140831 ';
Set sName = CONCAT (' tbl_ads_req_ ', ');
Set lName = ';
Set rest = 1;
While rest > 0 do
Set stime = (select Date_format (select Adddate (stime,1), '%y%m%d '));
Set lName = CONCAT (sname,stime);
Set Sqlvar=concat (' ALTER TABLE ', LName, ' Add app_package varchar (64) ');
Set @v_s =sqlvar;
Prepare stmt from @v_s;
EXECUTE stmt;
Set rest = DATEDIFF (etime,stime);
END while;
End
//
DELIMITER;
MySQL bulk Add new column stored procedure in table