1. 程式人生 > >幾乎死迴圈的儲存過程

幾乎死迴圈的儲存過程

測試用

create table test(num1 varchar(10),num2 varchar(100),num3 varchar(10));

drop procedure  test;

DELIMITER ;; 
CREATE PROCEDURE test() 
BEGIN 
DECLARE y varchar(100) DEFAULT 1;
WHILE y<=20000000
DO
insert into test(num1,num2,num3) values(y,y+1,y+2); 
SET y=y+1; 
END WHILE ; 
commit; 
END;; 

ALTER TABLE `test`.`test` ADD UNIQUE INDEX `test` (`num1` , `num2` );
ALTER TABLE `test`.`test` ADD UNIQUE INDEX `test1` (`num1`);
ALTER TABLE `test`.`test` ADD PRIMARY KEY (`num1`);

CALL test();