CREATE TABLE `test_table` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(45) DEFAULT NULL,
`age` int(11) DEFAULT NULL,
`address` varchar(45) DEFAULT NULL,
`score` int(3) DEFAULT NULL,
`class` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
DELIMITER ;;
CREATE PROCEDURE insert_test_data()
BEGIN
DECLARE i INT DEFAULT 1;
WHILE i <= 1000 DO
INSERT INTO test_table(name, age, address, score, class) VALUES (CONCAT('name_', i), FLOOR(100*RAND()+10), CONCAT('address_', i), FLOOR(100*RAND()+10), CONCAT('class_', FLOOR(10*RAND()+1)));
SET i = i + 1;
END WHILE;
END;;
DELIMITER ;
CALL insert_test_data();
标签:varchar,DEFAULT,创建,测试数据,int,mysql,NULL
From: https://www.cnblogs.com/darling331/p/17352087.html