实验五 SQL语言

发布时间 : 星期三 文章实验五 SQL语言更新完毕开始阅读

(3) 查询“大学计算机基础”课程考试成绩前三名的学生姓名和成绩。 select st_info.St_ID,St_Name,score from st_info

inner join s_c_info on st_info.St_ID=s_c_info.st_id inner join C_info on s_c_info.c_no=C_info.c_no and c_Name='大学计算机基础'

(4) 将s_c_info中的score列的值转为等级制输出,即60分以下显示为“不及格”,60~69分显示“及格”,70~79分显示“中等”,80~81显示“良好”,90~100显示“优秀”。要求输出学号、姓名、课程名、成绩等级。(提示:

在select字句中使用case…when…end语句) select St_info.st_id,St_name,C_Name,成绩等级= case

when score>=90 then '优秀' when score>=80 then '良好' when score>=70 then '中等' when score>=60 then '及格' when score<60 then '不及格' end

from s_c_info,St_info,C_Info

where St_info.st_id=s_c_info.st_id and C_Info.C_No=s_c_info.c_no

(二)SQL的增删改功能

在实验四建立的studb数据库中,写SQL语句实现增删改功能。 1.在S表中增加如下记录:

insert S

values('s3','张明华','男','1995-08-21 00:00:00.000','MA_数学','530.0','浙江杭州',NULL)

2. 在C表中将课程名为“数据库”的学分更改为3

update C set ccredit='3'

where cname='数据库'

3.删除S表中S2的学生记录,请问是否能删除,为什么,要如何操作。 能删除

delete from S where sno='S2'

(三)索引

在studb数据库中,分别用对象资源管理器和SQL语言定义索引 1.在对象资源管理器中,在T表的tname列上中建立聚集索引ix_tname,降序。查看聚集的效果。

联系合同范文客服:xxxxx#qq.com(#替换为@)