关于mysql数据表中一次性插入一千条记录的方法
test表中的结构如下:
DROP TABLE IF EXISTS `test`;
CREATE TABLE `test` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(20) default NULL,
`age` int(11) default NULL,
`property` varchar(20) default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
请问要一次性插入1000条记录怎么办?这一千条记录只是要求id号依次增加,其余的几个字段无要求
使用如下命令似乎不行啊,请教解决方法,谢谢了(ps:使用的是mysql)
mysql> declare @i int
-> set @i=1
-> while @i<=1000
-> begin
-> insert into test (id,name,age,property) values(@i,'name','age','property')
-> set @i=@i+1
-> 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 'declare @i int' at line 1