编辑代码

create database test;
use test;
create table student(
    sno char(9) primary key ,
    sname char(20),
    ssex char(2),
    sage smallint,
    sdept char(40),
    saddr char(100)
);

insert into student
values ('2022302849','靓为','男','18','dept1','合肥'),
       ('2022302850','丁龙','男','18','dept2','合肥'),
       ('2022302851','孟强','男','19','dept3','芜湖'),
       ('2022302852','黄源','男','19','dept4','六安')
;

#查询全部信息
select * from student;

#查询年龄大于18的信息
select * from student where sage>18;

#查询地址在合肥的信息
select * from student where saddr='合肥';

#将自己的年龄-1

update student
set sage=sage - 1
where sname = '靓为';

#查询全部信息
select * from student;