资源预览内容
第1页 / 共2页
第2页 / 共2页
亲,该文档总共2页全部预览完了,如果喜欢就下载吧!
资源描述
1. 向 t_course 表中添加一门课程,编号为 C021,名称为图像处理,教师未定。insert into t_course(courseno,coursename,teano) values(C021,图像处理,)2. 规定所有的男生都要选修 C021 课程,向 t_score 中添加课程 C021 的考试成 绩,每个男生的学号对应一个期中考试和期末考试,分数未定。insert into t_score select distinct t_student.stuno,type,C021, from t_student,t_score where t_student.stusex=男and t_score.stuno=t_student.stuno 3. 删除学号为 S0001 学生的 vb 期末考试成绩。delete from t_score where t_score.stuno=S0001 and t_score.courseno=(select courseno from t_course where t_course.coursename=vb) 4. 删除教师“梁天”教授的所有课程,以及这些课程所对应的考试记录。and delete from t_score where courseno=(select courseno from t_teacher,t_course where t_teacher.teano=t_course.teano and t_teacher.teaname=梁天)delete from t_course where courseno=(select courseno from t_teacher,t_course where t_teacher.teano=t_course.teano and t_teacher.teaname=梁天) 5. 假如在 t_course 中有 coursename 相同的课程记录,请删除这些记录。delete from t_course where coursename in (select coursename from t_course group by coursename having count(coursename)1); 6. 将郑义进的性别改为男。update t_student set stusex=男 where t_student.stuname=郑义进 7. 将梁天的职称改为教授。update t_teacher set teatitle=教授 where t_teacher.teaname=梁天 8. 将所有学生的姓名改为外国式,名在前,姓在后。update t_student stu set stuname=(select substr(stuname,2)|substr(stuname,1,1) from t_student where stu.stuno=t_student.stuno) 9. 删除考试平均分不及格的学生记录。delete from t_score where score=60 10. 现在要将期末平均分最低的课程更换教师,方法为:教师更换为教授平均分 最高的授课教师(取一个)update t_course set t_course.teano=(select teano from (select avg(score),t_course.teano from t_score ,t_course where t_score.type=期末 and t_score.courseno=t_course.coursenogroup by t_course.courseno,teano order by avg(score) desc)where rownum=1) where t_course.teano=( select teano from (select avg(score),t_course.teano from t_score ,t_course where t_score.type=期末 and t_score.courseno=t_course.coursenogroup by t_course.courseno,teano order by avg(score) asc)where rownum=1) 11. 删除各门课程尾巴学生的学籍。 (尾巴学生是指平均分在该课程所有学生平 均分中倒数第一) 。delete from t_student where t_student.stuno in (select stuno from t_score,t_course where t_score.courseno=t_course.courseno and score(select avg(score) from t_score ) group by coursename,stuno) 12. 现在要修改学生 vb 期末 score,将女生 score+20 分,男生 score+10 分, update 写一句。update t_score set score=decode( (select stusex from t_student where t_score.stuno=t_student.stuno),男,score+10,女,score+20)where courseno=(select courseno from t_course where t_course.coursename=vb) and t_score.type=期末
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号