Create a test table: MySQL> Create TableBigdata (IDint, nameChar(2) ; Create stored procedure: MySQL>Delimiter//MySQL> Create procedureRand_data (inchNumint) - begin - Declare Str Char( +)default 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';--a total of 62 characters. - Declarestr2Char(2); - DeclareIint default 0; - whileI<Num do - Setstr2=Concatsubstring(Str,1+ Floor(Rand()* A),1),substring(Str,1+ Floor(Rand()* A),1)); - SetI=I+1; - Insert intoBigdataValues( Floor(Rand()*num), str2); - End while; - End; - //Query OK,0Rows Affected (0.01sec) MySQL>delimiter; Insert 1 million data:
Mysql> call Rand_data (1000000);
Query OK, 1 row affected (1 hour min 34.95 sec)
Mysql> Select * fromBigdata limit -,Ten;+--------+------+|Id|Name|+--------+------+| 230085 |WR|| 184410 |7n|| 540545 |Nn|| 264578 |Tf|| 571507 |At|| 577023 |0M|| 731172 |7h|| 914168 |Ph|| 391848 |H6|| 665301 |Dj|+--------+------+TenRowsinch Set(0.00Sec
Insert data successfully.
MySQL BULK Insert random data Method--stored procedure