mysqlテストデータの生成
1.databaseの作成
2.データテーブルの作成
フィールドの種類:
id:番号uname:ユーザー名ucreatetime:作成時間age:年齢
3.挿入データ記憶プロセスの作成
上のv_cnt=1000000とは、何個のデータを挿入し、修正できるかを指します.
4.ストレージ・プロシージャの実行
create database test;
2.データテーブルの作成
フィールドの種類:
id:番号uname:ユーザー名ucreatetime:作成時間age:年齢
CREATE TABLE usertb(
id serial,
uname varchar(20) ,
ucreatetime datetime ,
age int(11))
ENGINE=innodb
DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci
AUTO_INCREMENT=1
ROW_FORMAT=COMPACT;
3.挿入データ記憶プロセスの作成
delimiter $$
SET AUTOCOMMIT = 0$$
create procedure test1()
begin
declare v_cnt decimal (10) default 0 ;
dd:loop
insert into usertb values
(null,' 1','2010-01-01 00:00:00',20),
(null,' 2','2010-01-01 00:00:00',20),
(null,' 3','2010-01-01 00:00:00',20),
(null,' 4','2010-01-01 00:00:00',20),
(null,' 5','2011-01-01 00:00:00',20),
(null,' 6','2011-01-01 00:00:00',20),
(null,' 7','2011-01-01 00:00:00',20),
(null,' 8','2012-01-01 00:00:00',20),
(null,' 9','2012-01-01 00:00:00',20),
(null,' 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 ;
上のv_cnt=1000000とは、何個のデータを挿入し、修正できるかを指します.
4.ストレージ・プロシージャの実行
call test1;