
-
-
- 1.删除学习“谌燕”老师课的SC 表记录;
- 2.查询c002课的平均成绩
- 3.查询没有上过c002课程的同学学号
- 4.向SC表中插入一些记录,这些记录要求符合以下条件:没有上过编号“c002”课程的同学学号、“c002”号课的平均成绩;
- 5.查询c001课成绩小于80分的同学的学号和分数
- 6.将c002课程的成绩增加5分
- 7.将c001课程成绩小于80分的同学的成绩增加10分
- 8.增加一个学生:学号's013',姓名:'王麻子',年龄:28,性别:男
- 9.找出没有选择c003课程的学生,并为他们选上c003课程,默认分类为60分
- 10.给所有女学生的成绩加10分
- 11.创建一张和sc表相同的表,并将s001和s002学生的选课信息插入新表中
- 12.将所有c001课程成绩低于平均成绩的同学的分数改为60分
- 13.删除学生s002学生选择c001课的记录
- 14、删除学习“谌燕”老师课的SC 表记录;
- 15.向SC表中插入一些记录,这些记录要求符合以下条件:没有上过编号“c002”课程的同学学号、“c002”号课的平均成绩;
- 16.删除“s002”同学的“c001”课程的成绩
- 17.将s001学生的所有课程成绩改为他自己的平均成绩
- 18.将s001学生的所有课程成绩改为各科的平均成绩
1.删除学习“谌燕”老师课的SC 表记录;
delete from sc
where cno in(select c.cno from teacher t,course cwhere c.tno=t.tno and t.tname='谌燕'
);
2.查询c002课的平均成绩
select avg(score)
from sc
where cno='c002';
3.查询没有上过c002课程的同学学号
select sno
from student
where sno not in(select sno from scwhere cno<>'c002';
);
4.向SC表中插入一些记录,这些记录要求符合以下条件:没有上过编号“c002”课程的同学学号、“c002”号课的平均成绩;
insert into sc(select sno,'c005',(select avg(score) from sc where cno='c002')from student where sno not in (select sno from sc where cno='c002')
);
5.查询c001课成绩小于80分的同学的学号和分数
select sno,score
from sc
where cno='c001' and score<80;
6.将c002课程的成绩增加5分
update sc
set score=score+5
where cno='c002';
7.将c001课程成绩小于80分的同学的成绩增加10分
update sc
set score=score+10
where cno='c001' and score<80;
8.增加一个学生:学号’s013’,姓名:‘王麻子’,年龄:28,性别:男
insert into student
values('s013','王麻子',28,'男');
insert into student
select 's013','王麻子',28,'男' from dual;
9.找出没有选择c003课程的学生,并为他们选上c003课程,默认分类为60分
insert into sc(select sno,'c003',60from student where sno not in(select sno from sc where cno='c003')
);
10.给所有女学生的成绩加10分
update sc
set score=score+10
where sno in (select sno from student where ssex='女'
);
11.创建一张和sc表相同的表,并将s001和s002学生的选课信息插入新表中
create table sc_bkp as
select * from sc where sno in('s001','s002');
select * from sc_bkp;
12.将所有c001课程成绩低于平均成绩的同学的分数改为60分
update sc
set score=60
where cno='c001' and score <(select avg(score) from sc
);
13.删除学生s002学生选择c001课的记录
delete from sc
where sno='s002' and cno='c001';
14、删除学习“谌燕”老师课的SC 表记录;
delete from sc
where cno in(select cnofrom course c,teacher twhere c.tno=t.tno and tname='谌燕'
);
15.向SC表中插入一些记录,这些记录要求符合以下条件:没有上过编号“c002”课程的同学学号、“c002”号课的平均成绩;
insert into sc(select sno,'c002',(select avg(score) from sc) from student where sno not in (select sno from sc where cno='c002')
);
16.删除“s002”同学的“c001”课程的成绩
update sc
set score=null
where sno='s002' and cno='c001';
17.将s001学生的所有课程成绩改为他自己的平均成绩
update sc
set score=(select avg(score) from sc)
where sno='s001';
18.将s001学生的所有课程成绩改为各科的平均成绩
update sc s1
set score=(select avg(score) from sc where cno=s1.cno)
where sno='s001';