用shell脚本在mysql表中批量插入数据的方法
#!/bin/bash
i=1;
MAX_INSERT_ROW_COUNT=$1;
while [ $i -le $MAX_INSERT_ROW_COUNT ]
do
mysql -uroot -proot afs -e "insert into afs_test (name,age,createTime) values ('HELLO$i',$i % 99,NOW());"
d=$(date +%M-%d\ %H\:%m\:%S)
echo "INSERT HELLO $i @@ $d"
i=$(($i+1))
sleep 0.05
done
exit 0;
sh create-data.sh 10000
博客介绍了用shell脚本在mysql表中批量插入数据的方法。给出了具体的shell脚本代码,通过循环实现数据插入,还展示了执行脚本的命令,如sh create-data.sh 10000 。
678

被折叠的 条评论
为什么被折叠?



