CREATE PROCEDURE dowfill_tablehile() BEGIN DECLARE v1 INT DEFAULT 5000000;
WHILE v1 > 0 DO INSERT INTO no_part(ttime) VALUES(DATE_ADD('2010-01-01 00:00:00', INTERVAL v1*10 MINUTE)); SET v1 = v1 - 1; END WHILE; END
你就insert into test select * from test,循环执行这句话,记录会按照2的n次方进行递增
mysql> CREATE PROCEDURE dowfill_tablehile() -> BEGIN -> DECLARE v1 INT DEFAULT 50; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3 mysql> mysql> WHILE v1 > 0 DO -> INSERT INTO aa(title) VALUES(DATE_ADD('2010-01-01 00:00:00', INTERVAL v1*10 MINUTE)); ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHILE v1 > 0 DO INSERT INTO aa(title) VALUES(DATE_ADD('2010-01-01 00:00:00',' at line 1 mysql> SET v1 = v1 - 1; ERROR 1193 (HY000): Unknown system variable 'v1' mysql> END WHILE; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'END W HILE' at line 1 mysql> END; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'END' at line 1
mysql>delimiter $$ mysql>create procedure dowfill_tablehile() -> begin -> declare v1 int default 50; -> while v1>0 do -> insert into aa (title) values (date_add('2010-01-01 00:00:00',interval v1*10 minute)); -> set v1=v1-1; -> end while; -> end $$ Query OK, 0 rows affected mysql>delimiter ;(0.00 sec)/code]
2. 在EXCEL中生成大量INSERT语句,然后 SOURCE
3. 用其它程序写脚本
CREATE PROCEDURE dowfill_tablehile()
BEGIN
DECLARE v1 INT DEFAULT 5000000;
WHILE v1 > 0 DO
INSERT INTO no_part(ttime) VALUES(DATE_ADD('2010-01-01 00:00:00', INTERVAL v1*10 MINUTE));
SET v1 = v1 - 1;
END WHILE;
END
-> BEGIN
-> DECLARE v1 INT DEFAULT 50;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '' at
line 3
mysql>
mysql> WHILE v1 > 0 DO
-> INSERT INTO aa(title) VALUES(DATE_ADD('2010-01-01 00:00:00', INTERVAL
v1*10 MINUTE));
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'WHILE
v1 > 0 DO
INSERT INTO aa(title) VALUES(DATE_ADD('2010-01-01 00:00:00',' at line 1
mysql> SET v1 = v1 - 1;
ERROR 1193 (HY000): Unknown system variable 'v1'
mysql> END WHILE;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'END W
HILE' at line 1
mysql> END;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'END'
at line 1
mysql>create procedure dowfill_tablehile()
-> begin
-> declare v1 int default 50;
-> while v1>0 do
-> insert into aa (title) values (date_add('2010-01-01 00:00:00',interval v1*10 minute));
-> set v1=v1-1;
-> end while;
-> end $$
Query OK, 0 rows affected
mysql>delimiter ;(0.00 sec)/code]