1、在EXCEL中生成所需SQL語句
alter table friend0 add column pknum int;
alter table friend99 add column pknum int;
2、用SP迴圈生成
SQL語句,再動態執行
DELIMITER $$
CREATE PROCEDURE dd1()
BEGIN
DECLARE i INT DEFAULT 0;
WHILE i
SET @s=CONCAT("alter table friend",i," add column pknum int;");
PREPARE stml FROM @s;
EXECUTE stml;
END WHILE;
END; $$
DELIMITER ;
1、在EXCEL中生成所需SQL語句
alter table friend0 add column pknum int;
alter table friend99 add column pknum int;
2、用SP迴圈生成
alter table friend0 add column pknum int;
SQL語句,再動態執行
DELIMITER $$
CREATE PROCEDURE dd1()
BEGIN
DECLARE i INT DEFAULT 0;
WHILE i
SET @s=CONCAT("alter table friend",i," add column pknum int;");
PREPARE stml FROM @s;
EXECUTE stml;
END WHILE;
END; $$
DELIMITER ;