温馨提示×

生成大量测试数据脚本

发布时间:2020-08-16 22:10:34 来源:ITPUB博客 阅读:134 作者:wzgchen 栏目:MySQL数据库
生成大量数据来测试:
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

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。