数据库上机练习题及答案(2)

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

_____________________________________________________________________________________________________________________________________________________________________6001请创建一个教师表teacher其中包括教师号,教师名,教师性别,教师系,教师职称,教师出生日期,要求,教师号为唯一,各字段命名为tnochar(3),tnamechar(8),tsexchar(2),tdeptchar(20),tglasschar(10),tcsrqdatecreatetableteacher(tnochar(3)unique,tnamechar(8),tsexchar(2),tdeptchar(20),tglasschar(10),tcsrqdate)_____________________________________________________________________________________________________________________________________________________________________6002用定义语句创建“宿舍表”shuse1,要求宿舍号ssh文本3,宿舍类别sslb文本2,床位数cws数字整型,宿舍长ssz文本10位,宿舍号,宿舍号为主键,并且不为空createtableshuse1(sshchar(3)primarykeynotnull,sslbchar(2),cwsnumber,sszchar(10));_____________________________________________________________________________________________________________________________________________________________________6003在课程”表course中增加一列教师号tno文本3,缺省值000altertablecourseaddtnochar(3)default'000'notnull;_____________________________________________________________________________________________________________________________________________________________________6004将教师”表teacher所属系(tdept)长度改为50,约束条件为不为空,缺省值为计算机系altertableteacheraltertdeptchar(50)notnulldefault'计算机系'_____________________________________________________________________________________________________________________________________________________________________6005创建一个名字为v_stu视图,将计算机系平均成绩大于等于80的同学的姓名及平均成绩放入该视图中。(注该视图只有名字和平均成绩两个字段,平均成绩要用pjgrade)表示createviewv_stuasselectsname,avg(grade)aspjgradefromstudent,scwherestudent.sno=sc.snoandsdept='计算机系'groupbysnamehavingavg(grade)=80;_____________________________________________________________________________________________________________________________________________________________________6006以SC表创建一个索引文件idx_sc1,要求按CNO降降序,GRADE升序createindexidx_sc1onsc(cnodesc,gradeasc);_____________________________________________________________________________________________________________________________________________________________________6007请创建一个视图文件sss,要求其中包括计算机系所有成绩大于70分课程的学生姓名,课程名,成绩,,系名,任课教师姓名。createviewsssasselectstudent.sname,cname,sc.grade,sdept,tnamefromstudent,course,sc,teacherwherestudent.sno=sc.snoandsc.cno=course.cnoandcourse.tno=teacher.tnoandsdept='计算机系'andsc.grade70_____________________________________________________________________________________________________________________________________________________________________6008请将course表中的tno列删除altertablecoursedroptno;_____________________________________________________________________________________________________________________________________________________________________6009建一视图sss1,要求其中包含每个人的姓名,平均成绩,最高成绩,最低成绩等字段,并用中文(姓名,平均成绩,最高成绩,最低成绩表示出来)createviewsss1asselectsnameas姓名,avg(grade)as平均成绩,max(grade)as最高成绩,min(grade)as最低成绩fromstudent,scwherestudent.sno=sc.snogroupbysname_____________________________________________________________________________________________________________________________________________________________________6010删除索引文件idx_sc1dropindexidx_sc1onsccreatetableshuse1(sshchar(3)notnull,sslbchar(2),cwsinteger,sszchar(10),check(cws=1andcws=4),primarykey(ssh));

1 / 3
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功