1 增加 (Create)

(1) 完全插入

insert classes values(0, "江湖菜鸟");
image.png
insert students values(0, "余沧海", 20, "男", 0, "1990-01-01");
image.png

(2) 部分插入

insert students(name, gender) values("黄蓉", "女");
image.png

(3) 多行插入

insert students(name, gender) values("摘星子", "男"), ("费彬", "男");
image.png

2 删除 (Delete)

(1) 物理删除

delete from students where name="黄蓉";
image.png

(2) 逻辑删除

用一个字段来表示,这条信息是否已经不能再使用了
给表添加一个is_delete字段, bit类型
alter table students add is_delete bit default 0;
update students set is_delete=1 where id=X;

3 改变 (Update)

update students set age=18,gender=2 where id=3;
image.png

4 查询 (Retrieve)

(1) 完全查询

select * from classes;
image.png

(2) 筛选查询

select * from students where gender=2;
image.png

(3) 指定字段查询

select name, gender from students;
image.png
select name as 姓名, gender as 性别 from students;
image.png

(4) 去重查询

select distinct gender from students;
image.png