五.按要求写出相应的SQL语句(每题2分,共20分)设有如下关系表stude
tsidchar8s
amechar10ssexchar2heightreal,sagedatetime,stli
tcoursecidchar4c
amechar10crediti
tresultsidchar8cidchar4scorei
t注:sid为学号(如09040105,09表示入学时间,04表示学院代号,01表示班级代号,05表示学号)s
ame为姓名ssex为性别(‘男’‘女’height为身高,sage为出生年月,stl表示高考总分;,)cid为课程号c
ame为课程名称credit为学分;score为课程成绩。写出实现下列功能的SQL语句。(1)创建一个新的表totalgrade具有数据列:sid,s
ame,sscoreCreatetabletotalgradesidchar8s
amechar10sscorei
t(2)在stude
t中插入一条记录(’09010619’’王鸿路’’032193’;,,)I
serti
tostude
t(sids
amesage)values‘09010619’’王鸿路’’032193’,(3)通过stude
t表,更新totalgrade表的列数据;I
serti
tototalgradeSelectsid,s
ame,stlfromstude
t(4)将result表中学号为“09030805”的学生,课程号为“0102”的分数改为94;Updateresultsetscore94Wheresid‘09030805’a
dcid‘1020’(5)通过result表更新totalgrade表的总成绩sscoreUpdatetotalgradesetsscoreselectsumscorefromresultwheretotalgradesidresultsid(6)删除totalgrade表中总成绩sscore低于400分的学生记录Deletefromtotalgradewheresscore400(7)在stude
t表中查询学号为09040302的同学的姓名和年龄Selects
amedatepartyygetdatedatepartyysagefromstude
twheresid’09040302’(8)在stude
t表中查询与“刘伟平”年龄相同的所有学生的学号、姓名Selectsids
amefromstude
twheresageselectsagefromstude
twheres
ame‘刘伟平’(9)列出班级为03的学生中高考总分比班级为02的学生都高的学生的sid,s
ame,stlSelectsids
ame,stlfromstude
twheresubstrsid52‘03’a
dstlallselectstlfromstude
twheresubstrsid52‘02’(10)查询选修“计算机基础”课程分数在8090之间的学生的学号、姓名、课程名称、分数
fSelectstude
tsidstude
ts
amecoursec
ameresultscoreFromstude
tcourseresultWherestude
tsidresultsida
dcoursecidresultcida
dcoursec
ame’计算机基础’a
dresultscorebetwee
80a
d90六、程序填空(每空2分,共20分)(主要是关于完整性约束、游标、存储过程、触发器)1.利用TSQL语言修改stude
t的表,为学号sid列定义主键,为高考总分stl列定义约束“0500”分。alteraddaddtablestude
tCo
strai
tpk_sprimarykey‘sid’Co
strai
tck_stlcheckstlbetwee
0a
d500
2以下程序用游标gd_cur查寻并显示stude
tsdb数据库的grade表的每r