Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mysql generates test data

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. Create databasecreate database test;2. create the data table

Field Type:

id : Number

uname: username

ucreatetime : creation time

Age : Age

CREATE TABLE usertb(id serial,uname varchar(20) ,ucreatetime datetime ,age int(11))ENGINE=innodbDEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ciAUTO_INCREMENT=1ROW_FORMAT=COMPACT;3. create insert datastore procedure elimiter $$SET AUTOCOMMIT = 0$$create procedure test1()begindeclare v_cnt decimal (10) default 0 ;dd:loop insert into usertb values (null,'User1','2010-01-01 00:00: 00', 20), (null,'User 2','2010-01-01 00:00: 00', 20), (null,'User 3','2010-01-01 00:00: 00', 20), (null,'User 4','2010-01-01 00:00: 00', 20), (null,'User 5','2011-01-01 00:00: 00', 20), (null,'User 6','2011-01-01 00:00: 00', 20), (null,'User 7','2011-01-01 00:00: 00', 20), (null,'User 8','2012-01-01 00:00: 00', 20), (null,'User 9','2012-01-01 00:00: 00', 20), (null,'User 0','2012-01-01 00:00: 00', 20) ; commit; set v_cnt = v_cnt+10 ; if v_cnt = 10000000 then leave dd; end if; end loop dd ;end;$$delimiter ;

The v_cnt = 1000000 above refers to how many pieces of data are inserted and can be modified.

4. Execute stored procedure call test1;

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report