1.创建t1表
CREATE TABLE t1
(id
int(11) NOT NULL AUTO_INCREMENT,a
int(11) DEFAULT NULL,b
int(11) DEFAULT NULL,
PRIMARY KEY (id
),
KEY idx_a
(a
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2.创建一个存储过程
drop PROCEDURE if EXISTS insert_t1;
delimiter ; ;
create PROCEDURE insert_t1()
BEGIN
DECLARE i int;
set i=1;
WHILE(i<10000) DO
INSERT into t1(a,b) VALUES(i,i);
set i=i+1;
END WHILE;
END;
delimiter ;;
3.调用存储过程
CALL insert_t1();