DROP
TABLE
IF EXISTS `mytab`;
CREATE
TABLE
`mytab` (
`id`
int
(10) unsigned
NOT
NULL
AUTO_INCREMENT,
`c1`
int
(11)
NOT
NULL
DEFAULT
‘0
',
`c2` int(11) NOT NULL DEFAULT ‘0'
,
`c3`
timestamp
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
ON
UPDATE
CURRENT_TIMESTAMP
,
`c4`
varchar
(200)
NOT
NULL
DEFAULT
”,
PRIMARY
KEY
(`id`)
) ENGINE=InnoDB;
DELIMITER $$$
DROP
PROCEDURE
IF EXISTS `insert_mytab`;
CREATE
PROCEDURE
`insert_mytab`(
in
rownum
int
,
in
commitrate
int
)
BEGIN
DECLARE
i
INT
DEFAULT
0;
SET
AUTOCOMMIT = 0;
WHILE i < rownum DO
INSERT
INTO
mytab(c1, c2, c3,c4)
VALUES
( FLOOR(RAND()*rownum),FLOOR(RAND()*rownum),NOW(), REPEAT(
CHAR
(ROUND(RAND()*255)),200));
SET
i = i+1; /* 达到每 COMMITRATE 频率时提交一次 */ IF (commitrate > 0)
AND
(i % commitrate = 0)
THEN
COMMIT
;
SELECT
CONCAT(‘commitrate: ‘, commitrate, ‘
in
‘, I);
END
IF;
END
WHILE;