mysql创建自动插入存储过程



DELIMITER $$ 
 
USE `jeesite`$$ 
 
DROP PROCEDURE IF EXISTS `autoinsert`$$ 
 
CREATE DEFINER=`root`@`localhost` PROCEDURE `autoinsert`(IN IP_NUM INT, IN OID_NUM INT) 
BEGIN 
  DECLARE iIP INT DEFAULT 0 ; 
  DECLARE iOID INT DEFAULT 0 ;    
   WHILE(iIP < IP_NUM) 
    DO 
      SET iOID = 0; 
      WHILE(iOID      DO 
        SET @mySql=CONCAT("INSERT INTO cms_user (ID, NAME,AGE,PLACE,DEPARTMENT,DESCRIPTION,CREATE_BY,
        CREATE_DATE,UPDATE_BY,UPDATE_DATE,REMARKS,DEL_FLAG) VALUES(uuid(),uuid(),
        (ROUND(RAND() * 100) + 1),uuid(),uuid(),uuid(),
        '1','2016-07-05 11:31:24','1','2016-07-05 11:31:24','1','0');");             
        PREPARE stmt FROM @mySql; 
        EXECUTE stmt;   
        DEALLOCATE PREPARE stmt;
        SET iOID = iOID+1;       
      END WHILE; 
        SET iIP = iIP+1; 
    END WHILE; 
 
    END$$ 
 
DELIMITER ;


call autoinsert(10,5);

你可能感兴趣的:(mysql,数据库)