ITPub博客

首页 > 数据库 > MySQL > 生成大量测试数据脚本

生成大量测试数据脚本

原创 MySQL 作者:wzgchen 时间:2016-05-19 10:00:34 0 删除 编辑
生成大量数据来测试:
create table t1 (id int not null primary key auto_increment,age int,name varchar(20),createtime date);
create index idx_age_name_create on t1(age,name,createtime);


vi create-data.sh
#!/bin/bash


i=1;
MAX_INSERT_ROW_COUNT=$1;
while [ $i -le $MAX_INSERT_ROW_COUNT ]
do
    mysql -uroot -p123456 test -e "insert into t1 (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

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

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

注册时间:2015-05-01

  • 博文量
    383
  • 访问量
    213573