ITPub博客

首页 > IT职业 > IT图书 > MySQL批量插入数据脚本

MySQL批量插入数据脚本

IT图书 作者:gabbro 时间:2021-09-09 09:37:54 0 删除 编辑

MySQL批量插入数据脚本

?


#!/bin/bashi=1;MAX_INSERT_ROW_COUNT=$1;while [ $i -le $MAX_INSERT_ROW_COUNT ]do  mysql -uroot -proot dbname -e "insert into tablename (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.05done exit 0

新建表格就可以了

?

1234 create table afs_test(name varchar()32,age int(32),createTime datetime

插入十万的数据为./jiaoben.sh 100000

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2873/viewspace-2811063/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-08-19

  • 博文量
    85
  • 访问量
    726