Query OK, 1 row affected (43.05 sec)
1 mysql> create table w0904procedure (wa char, wb char, wd char, wi char); 2 Query OK, 0 rows affected (0.00 sec) 3 4 mysql> INSERT INTO w0904procedure VALUES(NULL, 0, ‘www0904‘, ‘w0904d‘); 5 ERROR 1406 (22001): Data too long for column ‘wd‘ at row 1 6 7 mysql> desc w0904procedure; 8 +-------+---------+------+-----+---------+-------+ 9 | Field | Type | Null | Key | Default | Extra | 10 +-------+---------+------+-----+---------+-------+ 11 | wa | char(1) | YES | | NULL | | 12 | wb | char(1) | YES | | NULL | | 13 | wd | char(1) | YES | | NULL | | 14 | wi | char(1) | YES | | NULL | | 15 +-------+---------+------+-----+---------+-------+ 16 4 rows in set (0.00 sec) 17 18 mysql> DROP PROCEDURE IF EXISTS insert_many_rows_w0904; 19 Query OK, 0 rows affected (0.00 sec) 20 21 mysql> delimiter // 22 mysql> CREATE PROCEDURE insert_many_rows_w0904 (IN loops INT) 23 -> BEGIN 24 -> DECLARE v1 INT; 25 -> SET v1=loops; 26 -> WHILE v1 > 0 DO 27 -> INSERT INTO w0904procedure VALUES(NULL, 0, ‘w‘, ‘w‘); 28 -> SET v1 = v1 - 1; 29 -> END WHILE; 30 -> END; 31 -> // 32 Query OK, 0 rows affected (0.00 sec) 33 34 mysql> delimiter ; 35 mysql> 36 mysql> SET @loops=987987; 37 Query OK, 0 rows affected (0.00 sec) 38 39 mysql> CALL insert_many_rows_w0904(@loops); 40 Query OK, 1 row affected (43.05 sec) 41 42 43 44 mysql> SELECT * FROM w0904procedure LIMIT 20; 45 +------+------+------+------+ 46 | wa | wb | wd | wi | 47 +------+------+------+------+ 48 | NULL | 0 | w | w | 49 | NULL | 0 | w | w | 50 | NULL | 0 | w | w | 51 | NULL | 0 | w | w | 52 | NULL | 0 | w | w | 53 | NULL | 0 | w | w | 54 | NULL | 0 | w | w | 55 | NULL | 0 | w | w | 56 | NULL | 0 | w | w | 57 | NULL | 0 | w | w | 58 | NULL | 0 | w | w | 59 | NULL | 0 | w | w | 60 | NULL | 0 | w | w | 61 | NULL | 0 | w | w | 62 | NULL | 0 | w | w | 63 | NULL | 0 | w | w | 64 | NULL | 0 | w | w | 65 | NULL | 0 | w | w | 66 | NULL | 0 | w | w | 67 | NULL | 0 | w | w | 68 +------+------+------+------+ 69 20 rows in set (0.00 sec) 70 71 72 mysql> SELECT COUNT(*) FROM w0904procedure; 73 +----------+ 74 | COUNT(*) | 75 +----------+ 76 | 987988 | 77 +----------+ 78 1 row in set (0.00 sec)
文章来自:http://www.cnblogs.com/yuanjiangw/p/5838481.html