如: 我想在数据库 _friend 库中,所有表 friend0 ,friend1 ...friend99 等
增加 pknum 字段。字段类型 int
5 个解决方案
#1
alter table friend0 add column pknum int;
alter table friend1 add column pknum int;
alter table friend2 add column pknum int;
alter table friend3 add column pknum int;
alter table friend4 add column pknum int;
alter table friend5 add column pknum int;
alter table friend6 add column pknum int;
alter table friend7 add column pknum int;
alter table friend8 add column pknum int;
alter table friend9 add column pknum int;
alter table friend10 add column pknum int;
alter table friend11 add column pknum int;
alter table friend12 add column pknum int;
alter table friend13 add column pknum int;
alter table friend14 add column pknum int;
alter table friend15 add column pknum int;
alter table friend16 add column pknum int;
alter table friend17 add column pknum int;
alter table friend18 add column pknum int;
alter table friend19 add column pknum int;
alter table friend20 add column pknum int;
alter table friend21 add column pknum int;
alter table friend22 add column pknum int;
alter table friend23 add column pknum int;
alter table friend24 add column pknum int;
alter table friend25 add column pknum int;
alter table friend26 add column pknum int;
alter table friend27 add column pknum int;
alter table friend28 add column pknum int;
alter table friend29 add column pknum int;
alter table friend30 add column pknum int;
alter table friend31 add column pknum int;
alter table friend32 add column pknum int;
alter table friend33 add column pknum int;
alter table friend34 add column pknum int;
alter table friend35 add column pknum int;
alter table friend36 add column pknum int;
alter table friend37 add column pknum int;
alter table friend38 add column pknum int;
alter table friend39 add column pknum int;
alter table friend40 add column pknum int;
alter table friend41 add column pknum int;
alter table friend42 add column pknum int;
alter table friend43 add column pknum int;
alter table friend44 add column pknum int;
alter table friend45 add column pknum int;
alter table friend46 add column pknum int;
alter table friend47 add column pknum int;
alter table friend48 add column pknum int;
alter table friend49 add column pknum int;
alter table friend50 add column pknum int;
alter table friend51 add column pknum int;
alter table friend52 add column pknum int;
alter table friend53 add column pknum int;
alter table friend54 add column pknum int;
alter table friend55 add column pknum int;
alter table friend56 add column pknum int;
alter table friend57 add column pknum int;
alter table friend58 add column pknum int;
alter table friend59 add column pknum int;
alter table friend60 add column pknum int;
alter table friend61 add column pknum int;
alter table friend62 add column pknum int;
alter table friend63 add column pknum int;
alter table friend64 add column pknum int;
alter table friend65 add column pknum int;
alter table friend66 add column pknum int;
alter table friend67 add column pknum int;
alter table friend68 add column pknum int;
alter table friend69 add column pknum int;
alter table friend70 add column pknum int;
alter table friend71 add column pknum int;
alter table friend72 add column pknum int;
alter table friend73 add column pknum int;
alter table friend74 add column pknum int;
alter table friend75 add column pknum int;
alter table friend76 add column pknum int;
alter table friend77 add column pknum int;
alter table friend78 add column pknum int;
alter table friend79 add column pknum int;
alter table friend80 add column pknum int;
alter table friend81 add column pknum int;
alter table friend82 add column pknum int;
alter table friend83 add column pknum int;
alter table friend84 add column pknum int;
alter table friend85 add column pknum int;
alter table friend86 add column pknum int;
alter table friend87 add column pknum int;
alter table friend88 add column pknum int;
alter table friend89 add column pknum int;
alter table friend90 add column pknum int;
alter table friend91 add column pknum int;
alter table friend92 add column pknum int;
alter table friend93 add column pknum int;
alter table friend94 add column pknum int;
alter table friend95 add column pknum int;
alter table friend96 add column pknum int;
alter table friend97 add column pknum int;
alter table friend98 add column pknum int;
alter table friend99 add column pknum int;
alter table friend1 add column pknum int;
alter table friend2 add column pknum int;
alter table friend3 add column pknum int;
alter table friend4 add column pknum int;
alter table friend5 add column pknum int;
alter table friend6 add column pknum int;
alter table friend7 add column pknum int;
alter table friend8 add column pknum int;
alter table friend9 add column pknum int;
alter table friend10 add column pknum int;
alter table friend11 add column pknum int;
alter table friend12 add column pknum int;
alter table friend13 add column pknum int;
alter table friend14 add column pknum int;
alter table friend15 add column pknum int;
alter table friend16 add column pknum int;
alter table friend17 add column pknum int;
alter table friend18 add column pknum int;
alter table friend19 add column pknum int;
alter table friend20 add column pknum int;
alter table friend21 add column pknum int;
alter table friend22 add column pknum int;
alter table friend23 add column pknum int;
alter table friend24 add column pknum int;
alter table friend25 add column pknum int;
alter table friend26 add column pknum int;
alter table friend27 add column pknum int;
alter table friend28 add column pknum int;
alter table friend29 add column pknum int;
alter table friend30 add column pknum int;
alter table friend31 add column pknum int;
alter table friend32 add column pknum int;
alter table friend33 add column pknum int;
alter table friend34 add column pknum int;
alter table friend35 add column pknum int;
alter table friend36 add column pknum int;
alter table friend37 add column pknum int;
alter table friend38 add column pknum int;
alter table friend39 add column pknum int;
alter table friend40 add column pknum int;
alter table friend41 add column pknum int;
alter table friend42 add column pknum int;
alter table friend43 add column pknum int;
alter table friend44 add column pknum int;
alter table friend45 add column pknum int;
alter table friend46 add column pknum int;
alter table friend47 add column pknum int;
alter table friend48 add column pknum int;
alter table friend49 add column pknum int;
alter table friend50 add column pknum int;
alter table friend51 add column pknum int;
alter table friend52 add column pknum int;
alter table friend53 add column pknum int;
alter table friend54 add column pknum int;
alter table friend55 add column pknum int;
alter table friend56 add column pknum int;
alter table friend57 add column pknum int;
alter table friend58 add column pknum int;
alter table friend59 add column pknum int;
alter table friend60 add column pknum int;
alter table friend61 add column pknum int;
alter table friend62 add column pknum int;
alter table friend63 add column pknum int;
alter table friend64 add column pknum int;
alter table friend65 add column pknum int;
alter table friend66 add column pknum int;
alter table friend67 add column pknum int;
alter table friend68 add column pknum int;
alter table friend69 add column pknum int;
alter table friend70 add column pknum int;
alter table friend71 add column pknum int;
alter table friend72 add column pknum int;
alter table friend73 add column pknum int;
alter table friend74 add column pknum int;
alter table friend75 add column pknum int;
alter table friend76 add column pknum int;
alter table friend77 add column pknum int;
alter table friend78 add column pknum int;
alter table friend79 add column pknum int;
alter table friend80 add column pknum int;
alter table friend81 add column pknum int;
alter table friend82 add column pknum int;
alter table friend83 add column pknum int;
alter table friend84 add column pknum int;
alter table friend85 add column pknum int;
alter table friend86 add column pknum int;
alter table friend87 add column pknum int;
alter table friend88 add column pknum int;
alter table friend89 add column pknum int;
alter table friend90 add column pknum int;
alter table friend91 add column pknum int;
alter table friend92 add column pknum int;
alter table friend93 add column pknum int;
alter table friend94 add column pknum int;
alter table friend95 add column pknum int;
alter table friend96 add column pknum int;
alter table friend97 add column pknum int;
alter table friend98 add column pknum int;
alter table friend99 add column pknum int;
#2
不是吧,有没有简单的一条执行语句
#3
没有一条语句可以实现的方法。 必须用多条语句。可以通过程序得到表名,然后代码循环处理。
#4
alter table tb add column 列名 数据类型
每个表顺序执行一遍就可以了。
每个表顺序执行一遍就可以了。
#5
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<=99 DO
SET @s=CONCAT('alter table friend',i,' add column pknum int;');
PREPARE stml FROM @s;
EXECUTE stml;
END WHILE;
END; $$
DELIMITER ;
#1
alter table friend0 add column pknum int;
alter table friend1 add column pknum int;
alter table friend2 add column pknum int;
alter table friend3 add column pknum int;
alter table friend4 add column pknum int;
alter table friend5 add column pknum int;
alter table friend6 add column pknum int;
alter table friend7 add column pknum int;
alter table friend8 add column pknum int;
alter table friend9 add column pknum int;
alter table friend10 add column pknum int;
alter table friend11 add column pknum int;
alter table friend12 add column pknum int;
alter table friend13 add column pknum int;
alter table friend14 add column pknum int;
alter table friend15 add column pknum int;
alter table friend16 add column pknum int;
alter table friend17 add column pknum int;
alter table friend18 add column pknum int;
alter table friend19 add column pknum int;
alter table friend20 add column pknum int;
alter table friend21 add column pknum int;
alter table friend22 add column pknum int;
alter table friend23 add column pknum int;
alter table friend24 add column pknum int;
alter table friend25 add column pknum int;
alter table friend26 add column pknum int;
alter table friend27 add column pknum int;
alter table friend28 add column pknum int;
alter table friend29 add column pknum int;
alter table friend30 add column pknum int;
alter table friend31 add column pknum int;
alter table friend32 add column pknum int;
alter table friend33 add column pknum int;
alter table friend34 add column pknum int;
alter table friend35 add column pknum int;
alter table friend36 add column pknum int;
alter table friend37 add column pknum int;
alter table friend38 add column pknum int;
alter table friend39 add column pknum int;
alter table friend40 add column pknum int;
alter table friend41 add column pknum int;
alter table friend42 add column pknum int;
alter table friend43 add column pknum int;
alter table friend44 add column pknum int;
alter table friend45 add column pknum int;
alter table friend46 add column pknum int;
alter table friend47 add column pknum int;
alter table friend48 add column pknum int;
alter table friend49 add column pknum int;
alter table friend50 add column pknum int;
alter table friend51 add column pknum int;
alter table friend52 add column pknum int;
alter table friend53 add column pknum int;
alter table friend54 add column pknum int;
alter table friend55 add column pknum int;
alter table friend56 add column pknum int;
alter table friend57 add column pknum int;
alter table friend58 add column pknum int;
alter table friend59 add column pknum int;
alter table friend60 add column pknum int;
alter table friend61 add column pknum int;
alter table friend62 add column pknum int;
alter table friend63 add column pknum int;
alter table friend64 add column pknum int;
alter table friend65 add column pknum int;
alter table friend66 add column pknum int;
alter table friend67 add column pknum int;
alter table friend68 add column pknum int;
alter table friend69 add column pknum int;
alter table friend70 add column pknum int;
alter table friend71 add column pknum int;
alter table friend72 add column pknum int;
alter table friend73 add column pknum int;
alter table friend74 add column pknum int;
alter table friend75 add column pknum int;
alter table friend76 add column pknum int;
alter table friend77 add column pknum int;
alter table friend78 add column pknum int;
alter table friend79 add column pknum int;
alter table friend80 add column pknum int;
alter table friend81 add column pknum int;
alter table friend82 add column pknum int;
alter table friend83 add column pknum int;
alter table friend84 add column pknum int;
alter table friend85 add column pknum int;
alter table friend86 add column pknum int;
alter table friend87 add column pknum int;
alter table friend88 add column pknum int;
alter table friend89 add column pknum int;
alter table friend90 add column pknum int;
alter table friend91 add column pknum int;
alter table friend92 add column pknum int;
alter table friend93 add column pknum int;
alter table friend94 add column pknum int;
alter table friend95 add column pknum int;
alter table friend96 add column pknum int;
alter table friend97 add column pknum int;
alter table friend98 add column pknum int;
alter table friend99 add column pknum int;
alter table friend1 add column pknum int;
alter table friend2 add column pknum int;
alter table friend3 add column pknum int;
alter table friend4 add column pknum int;
alter table friend5 add column pknum int;
alter table friend6 add column pknum int;
alter table friend7 add column pknum int;
alter table friend8 add column pknum int;
alter table friend9 add column pknum int;
alter table friend10 add column pknum int;
alter table friend11 add column pknum int;
alter table friend12 add column pknum int;
alter table friend13 add column pknum int;
alter table friend14 add column pknum int;
alter table friend15 add column pknum int;
alter table friend16 add column pknum int;
alter table friend17 add column pknum int;
alter table friend18 add column pknum int;
alter table friend19 add column pknum int;
alter table friend20 add column pknum int;
alter table friend21 add column pknum int;
alter table friend22 add column pknum int;
alter table friend23 add column pknum int;
alter table friend24 add column pknum int;
alter table friend25 add column pknum int;
alter table friend26 add column pknum int;
alter table friend27 add column pknum int;
alter table friend28 add column pknum int;
alter table friend29 add column pknum int;
alter table friend30 add column pknum int;
alter table friend31 add column pknum int;
alter table friend32 add column pknum int;
alter table friend33 add column pknum int;
alter table friend34 add column pknum int;
alter table friend35 add column pknum int;
alter table friend36 add column pknum int;
alter table friend37 add column pknum int;
alter table friend38 add column pknum int;
alter table friend39 add column pknum int;
alter table friend40 add column pknum int;
alter table friend41 add column pknum int;
alter table friend42 add column pknum int;
alter table friend43 add column pknum int;
alter table friend44 add column pknum int;
alter table friend45 add column pknum int;
alter table friend46 add column pknum int;
alter table friend47 add column pknum int;
alter table friend48 add column pknum int;
alter table friend49 add column pknum int;
alter table friend50 add column pknum int;
alter table friend51 add column pknum int;
alter table friend52 add column pknum int;
alter table friend53 add column pknum int;
alter table friend54 add column pknum int;
alter table friend55 add column pknum int;
alter table friend56 add column pknum int;
alter table friend57 add column pknum int;
alter table friend58 add column pknum int;
alter table friend59 add column pknum int;
alter table friend60 add column pknum int;
alter table friend61 add column pknum int;
alter table friend62 add column pknum int;
alter table friend63 add column pknum int;
alter table friend64 add column pknum int;
alter table friend65 add column pknum int;
alter table friend66 add column pknum int;
alter table friend67 add column pknum int;
alter table friend68 add column pknum int;
alter table friend69 add column pknum int;
alter table friend70 add column pknum int;
alter table friend71 add column pknum int;
alter table friend72 add column pknum int;
alter table friend73 add column pknum int;
alter table friend74 add column pknum int;
alter table friend75 add column pknum int;
alter table friend76 add column pknum int;
alter table friend77 add column pknum int;
alter table friend78 add column pknum int;
alter table friend79 add column pknum int;
alter table friend80 add column pknum int;
alter table friend81 add column pknum int;
alter table friend82 add column pknum int;
alter table friend83 add column pknum int;
alter table friend84 add column pknum int;
alter table friend85 add column pknum int;
alter table friend86 add column pknum int;
alter table friend87 add column pknum int;
alter table friend88 add column pknum int;
alter table friend89 add column pknum int;
alter table friend90 add column pknum int;
alter table friend91 add column pknum int;
alter table friend92 add column pknum int;
alter table friend93 add column pknum int;
alter table friend94 add column pknum int;
alter table friend95 add column pknum int;
alter table friend96 add column pknum int;
alter table friend97 add column pknum int;
alter table friend98 add column pknum int;
alter table friend99 add column pknum int;
#2
不是吧,有没有简单的一条执行语句
#3
没有一条语句可以实现的方法。 必须用多条语句。可以通过程序得到表名,然后代码循环处理。
#4
alter table tb add column 列名 数据类型
每个表顺序执行一遍就可以了。
每个表顺序执行一遍就可以了。
#5
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<=99 DO
SET @s=CONCAT('alter table friend',i,' add column pknum int;');
PREPARE stml FROM @s;
EXECUTE stml;
END WHILE;
END; $$
DELIMITER ;