数据库
首页 > 数据库> > MySQL使用bash脚本造数据

MySQL使用bash脚本造数据

作者:互联网

create database test001;


use test001

CREATE TABLE runoob_tbl(
runoob_id INT NOT NULL AUTO_INCREMENT,
runoob_title VARCHAR(100) NOT NULL,
runoob_author VARCHAR(40) NOT NULL,
submission_date DATE,
PRIMARY KEY (runoob_id)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;

#!/bin/bash

i=1;
MAX_INSERT_ROW_COUNT=$1;
while [ $i -le $MAX_INSERT_ROW_COUNT ]
do
    mysql -uroot -pBccdr@123456 test001 -e "insert into runoob_tbl (runoob_id,runoob_title,runoob_author) 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 xx.sh 1000

标签:脚本,INSERT,test001,runoob,COUNT,MySQL,NULL,id,bash
来源: https://www.cnblogs.com/automata/p/15925177.html