mysql 创建procedure

    DROP PROCEDURE dowhile;  
    create PROCEDURE dowhile()  
    BEGIN  
        DECLARE i int DEFAULT 0;  
        START TRANSACTION;--定义事务  
              WHILE i<100 DO  
                    INSERT INTO user_basic(username,`password`,location,email,sex,`sign`,headImg,lastLogin,grade,inTime)  
                            VALUES(CONCAT('username',i),CONCAT('password',i),CONCAT('福田 ',i),CONCAT('username@test',i,'.com'),1,CONCAT('这是测试 ',i),'',now(),10+i,now());  
            set i=i+1;  
              END WHILE;  
        COMMIT;--开始执行事务  
    END  

call dowhile;--调用过程
 

猜你喜欢

转载自javaeedevelop.iteye.com/blog/1512981