MySQL 中同时输入多个数据?
以下为语法 −
insert into yourTableName values(yourValue1,yourValue2,.....N), (yourValue1,yourValue2,.....N), (yourValue1,yourValue2,.....N), (yourValue1,yourValue2,.....N), . . . N
让我们创建一个表 −
mysql> create table demo56 −> ( −> id int, −> first_name varchar(20), −> last_name varchar(20), −> age int −> ); Query OK, 0 rows affected (1.91 sec)
在表中插入一些记录,利用 insert 命令 −
mysql> insert into demo56 values(1,'John','Smith',23), −> (2,'David','Miller',21), −> (3,'Chris','Brown',22), −> (4,'Carol','Taylor',20); Query OK, 4 rows affected (0.10 sec) Records: 4 Duplicates: 0 Warnings: 0
使用 select 语句显示表中记录 −
mysql> select *from demo56;
这将产生如下的输出 −
+------+------------+-----------+------+ | id | first_name | last_name | age | +------+------------+-----------+------+ | 1 | John | Smith | 23 | | 2 | David | Miller | 21 | | 3 | Chris | Brown | 22 | | 4 | Carol | Taylor | 20 | +------+------------+-----------+------+ 4 rows in set (0.00 sec)
广告