MySQL批量插入資料指令碼

來源:互聯網
上載者:User

MySQL批量插入資料指令碼

MySQL批量插入資料指令碼

#!/bin/bash
i=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.05
done

exit 0

建立表格就可以了
create table afs_test(
name varchar()32,
age  int(32),
createTime datetime

插入十萬的資料為./jiaoben.sh 100000

本文永久更新連結地址:

 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.