加入收藏 | 设为首页 | 会员中心 | 我要投稿 PHP编程网 - 黄冈站长网 (http://www.0713zz.com/)- 数据应用、建站、人体识别、智能机器人、语音技术!
当前位置: 首页 > 站长学院 > MySql教程 > 正文

生成大量测验数据脚本

发布时间:2022-03-22 19:57:52 所属栏目: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_CO
      生成大量数据来测试:
      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

(编辑:PHP编程网 - 黄冈站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读