第3次作业-SQL语句的基本使用2(修改表-基本查询)

1.alter table curriculum drop 课程名称;

2.alter table grade modify 分数 decimal(5,2);

3.alter table student_info add 备注 varchar(50);

4. use studb;
Database changed
mysql> create table stu
    -> (学号 char(4) not null,
    -> 姓名 char(8) not null,
    -> 性别 char(2),
    -> 出生日期 date,
    -> 家庭住址 varchar(50),
    -> 备注 varchar(50),
    -> primary key(学号));


5.delete  from stu where 学号='0004';

6.update stu set 家庭住址='滨江市新建路96号' where 学号='0002';

7. alter table stu drop 备注;

8.(1)select 学号,姓名,出生日期 from student_info;

8.(2)select 姓名,家族住址 from student_info where 学号='0002';

8.(3) select 姓名,出生日期 from student_info where 出生日期>'1995-01-01'and 性别='女';

9.(1)select 学号,课程编号,分数 from grade where 分数 between 70 and 80;

9.(2)select avg(分数) from grade where 课程编号='0002';

9.(3)select count(*)as 选修课人数和有成绩的人数 from grade where 课程编号='0003' and 分数!=' ';

9.(4)select 姓名,出生日期 from student_info order by 出生日期 desc;

9.(5)select 学号,姓名 from student_info where 姓名 like '张%';

posted @ 2023-09-25 18:25  sun乔  阅读(23)  评论(0)    收藏  举报