生成大量测试数据脚本

生成大量数据来测试:
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

网页题目:生成大量测试数据脚本
网页地址:http://csdahua.cn/article/jdecci.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流