MySql插入单条或多条记录

插入记录

book表结构:

mysql> describe book;
+-------------+--------------+------+-----+---------+-------+
| Field       | Type         | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+-------+
| book_id     | int          | NO   | PRI | NULL    |       |
| title       | varchar(128) | YES  |     | NULL    |       |
| description | varchar(512) | YES  |     | NULL    |       |
| published   | date         | YES  |     | NULL    |       |
| author_id   | int          | YES  | MUL | NULL    |       |
| price       | float        | YES  |     | NULL    |       |
| rating      | int          | YES  |     | NULL    |       |
+-------------+--------------+------+-----+---------+-------+

author表结构:

mysql> describe author;
+-----------+-------------+------+-----+---------+-------+
| Field     | Type        | Null | Key | Default | Extra |
+-----------+-------------+------+-----+---------+-------+
| author_id | int         | NO   | PRI | NULL    |       |
| name      | varchar(45) | YES  |     | NULL    |       |
| email     | varchar(45) | YES  |     | NULL    |       |
+-----------+-------------+------+-----+---------+-------+

插入author表单条记录:

 insert into author values(10,'Cay Horstmann','horstmann@gmail.com');

插入author表多条记录:

 insert into author values
 (11,'Dane Cameron','cameron@gmail.com'),
 (12,'Richard Warbuton','richard@gmail.com'),
 (13,'Bruce Eckel','bruce@gmail.com'),
 (14,'Joshua Bloch','bloch@gmail.com');

插入book表多条记录:

insert into book values(8,'Effective java','core java Best practices',20080508,14,33.63,4),
(9,'Java SE 8 for Really impatient','Master java8',20140124,10,37,4),
(10,'Java 8:The fundamentals','Learn the fundamentals of java8',20140315,11,28,4),
(11,'java 8 Lambdas','mastering pragmatic functional programming',20140417,12,32,4),
(12,'java Puzzlers','java Traps,Pitfals,and Comer cases',20050704,14,40.2,5),
(13,'Core java for the Impatient','Masting Core java',20150212,10,35.96,3),
(14,'Object-Oriented Design and Patterns','Mastering OOP design',20050602,10,122.35,4),
(15,'Thinging in C++','Mastering C++',20000325,13,59.13,5);
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值