Mysql batch Add a new column stored procedure in the table, mysql new
Generally, for websites with a large access volume, the request log table is created independently on a daily basis. The business needs to add a new column for each table. After a long time, the stored procedure is as follows:
Log table structure type tbl_ads_req_20140801, tbl_ads_req_20140802...
DELIMITER //create procedure sp2()begindeclare 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;
Some mysql functions need to be checked by yourself!
How does mysql batch change a column of data?
The question is, are there any rules on the data you want to change?
As you wrote ,......, 25, 26. If there is a rule, it's easy.
You can use the Stored Procedure for batch processing.
Mysql batch insert
Saved as. SQL script
Then open the mysql command line,
Go to the directory where the script is stored (cd ).
Input: \. Full path of the SQL statement (including the SQL file name. Note that the path should be separated)
Enter
You can import data in batches.