【案例】:向创建出来的学生表中插入五个值
insert into t_student values(1 , 'zhangsan' , 'm' , 20 , '21zhangsan@123.com');
insert into t_student values(2 , 'lisi' , 'f' , 20 , '21lisi@123.com');
insert into t_student values(3 , 'wangwu' , 'f' , 20 , '21wangwu@123.com' );
insert into t_student values(4 , 'zhaoliu' , 'm' , 18 , '21zhaoliu@123.com');
insert into t_student values (5 , 'songqi' , 'm' , 19 , '21songqi@123.com');
mysql> select * from t_student;
+------+----------+------+------+--------------------+
| no | name | sex | age | email |
+------+----------+------+------+--------------------+
| 1 | zhangsan | m | 20 | 21zhangsan@123.com |
| 2 | lisi | f | 20 | 21lisi@123.com |
| 3 | wangwu | f | 20 | 21wangwu@123.com |
| 4 | zhaoliu | m | 18 | 21zhaoliu@123.com |
| 5 | songqi | m | 19 | 21songqi@123.com |
+------+----------+------+------+--------------------+
5 rows in set (0.00 sec)
【学生表的结构】:
mysql> desc t_student;
+-------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| no | int(11) | YES | | NULL | |
| name | varchar(32) | YES | | NULL | |
| sex | char(1) | YES | | m | |
| age | int(11) | YES | | NULL | |
| email | varchar(255) | YES | | NULL | |
+-------+--------------+------+-----+---------+-------+
5 rows in set (0.00 sec)
now() 获取系统当前时间
【案例】:插入李四的信息
insert into t_user (id ,name , birth , create_time) values (2 ,'lisi','2002-10-2',now());
//insert 一次插入多条数据
【案例】:向t_user中一次插入多条数据
insert into t_user values(1 , 'zhangsan' , '2000-10-01' , now()),
(2 , 'lisi' , '2001-01-11' , now()) , (3 , 'wangwu' , '2002-10-02' , now()),
(4 , 'zhaoliu' , '2003-6-8' , now()), (5 , 'songqi' , '2000-12-21' , now());
【案例】:将查询结果插入到一张表之中
create table dept_bak as select * from dept ;
insert into dept_bak select * from dept ;