新增、修改、删除表数据
插入记录:
mysql
insert into student(name,gender,birthday,score)
values('zhangsan','m','1999-2-2',70);
insert into student
values(null,'lisi','m','1997-2-2',80);
insert into student
values(null,'wangwu','m','1989-2-2',75);
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
查询表中所有学生的信息:
mysql
select * from student;
1
得到:
id | name | gender | birthday | score |
---|---|---|---|---|
1 | zhangsan | m | 1999-02-02 | 70 |
2 | lisi | m | 1997-02-02 | 80 |
3 | wangwu | m | 1989-02-02 | 75 |
修改student表中所有学生的成绩,加10分特长分:
mysql
update student set score=score+10;
1
修改 student 表中 zhangsan 的成绩,将成绩改为 98 分:
mysql
update student set score=98 where name='zhangsan';
1
删除性别是w的数据:
mysql
delete from student where gender='w';
1
删除表中所有数据,数据还能找回:
mysql
delete from student;
1
清空表数据,效率高,但是数据找不回:
mysql
truncate studen;
1