Memo: 1. The search found that MySQL does not support the direct write SQL statement to implement the loop insertion function. To implement this feature, you can either manipulate MySQL in another language, or use a stored procedure to implement it (store PROCEDURE--SP). 2. The following is an SP implementation pass, write down to be afraid to forget. --Table structure definition Tdefuser, there is an auto-increment PK:
T able create table ------------------------------------------------------------------ tdefuser create table ' Tdefuser ' ( ' UserId ' int (one) not null auto_increment, ' Address ' varchar ( default)  NULL,&NBSP ' phone ' varchar ( default null, ); primary key (' userId ') )  ENGINE=MYISAM AUTO_INCREMENT=10001 DEFAULT CHARSET=LATIN1&NBSP |
/tbody>
--Stored procedure implementation, AutoInsert:
DELIMITER $$
DROP PROCEDURE IF EXISTS `hibernate`.`autoInsert`$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `autoInsert`() BEGIN DECLARE i int default 1; WHILE(i < 10000) DO insert into tdefuser(address, phone) value (‘sz‘, ‘123‘); SET i = i+1; END WHILE; END$$
DELIMITER ;
|
--Complete, call AutoInsert (); invoke the SP.
mysql--loop insert data into table