MySQL批量插入数据脚本

DELIMITER $$
CREATE FUNCTION randVarchar(maxlength INT) RETURNS VARCHAR(255)
BEGIN
    DECLARE alphabet VARCHAR(62) DEFAULT
    'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
		
    DECLARE randvarchar VARCHAR(255)DEFAULT'';
		
    DECLARE i INT DEFAULT 0;
		
WHILE 
			i<maxlength
DO
    SET randvarchar= CONCAT(randvarchar,SUBSTR(alphabet,CEIL(RAND()*62),1));
    SET i=i+1;
END WHILE;
	
RETURN randvarchar;
END $$
#####################################################
CREATE PROCEDURE insertTable(IN maxInsert INT)
BEGIN
    DECLARE i INT DEFAULT 0;
    insertLOOP:LOOP
			
		INSERT INTO  HUMANMESSAGE VALUES (randvarchar(18),randvarchar(3),NULL);
		IF i=maxInsert THEN LEAVE insertLOOP;
		END IF;
		SET i=i+1;
    END LOOP ;
END $$

今天还学了一个新东西,ctfmon.exe

你可能感兴趣的:(MySQL)