1 增加 (Create)
(1) 完全插入
insert classes values(0, "江湖菜鸟");
insert students values(0, "余沧海", 20, "男", 0, "1990-01-01");
(2) 部分插入
insert students(name, gender) values("黄蓉", "女");
(3) 多行插入
insert students(name, gender) values("摘星子", "男"), ("费彬", "男");
2 删除 (Delete)
(1) 物理删除
delete from students where name="黄蓉";
(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;
4 查询 (Retrieve)
(1) 完全查询
(2) 筛选查询
select * from students where gender=2;
(3) 指定字段查询
select name, gender from students;
select name as 姓名, gender as 性别 from students;
(4) 去重查询
select distinct gender from students;