MySQL工作日志-给相同前缀库里的相同前缀表添加字段
时间:2010-10-27 来源:nianzong
alter table `$j` add `zoneID` int(6) NOT NULL default 0;
去掉反引号,否则shell会误认作shell命令:
for i in $db;
do
tb=$(mysql -uroot -p123456 -e "use $i;show tables"|grep "user_");
echo ===$i====;
for j in $tb;
do echo $j;
mysql -uroot -p123456 -e "use $i;alter table $j add zoneID int(6) NOT NULL default 0;"
done;
done
去掉反引号,否则shell会误认作shell命令:
for i in $db;
do
tb=$(mysql -uroot -p123456 -e "use $i;show tables"|grep "user_");
echo ===$i====;
for j in $tb;
do echo $j;
mysql -uroot -p123456 -e "use $i;alter table $j add zoneID int(6) NOT NULL default 0;"
done;
done
相关阅读 更多 +