ImageVerifierCode 换一换
格式:DOCX , 页数:5 ,大小:16.08KB ,
资源ID:888313      下载积分:5 文钱
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,省得不是一点点
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.wenke99.com/d-888313.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: QQ登录   微博登录 

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(数据库练习参考答案.docx)为本站会员(h****)主动上传,文客久久仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知文客久久(发送邮件至hr@wenke99.com或直接QQ联系客服),我们立即给予删除!

数据库练习参考答案.docx

1、根据给出的表结构完成以下题目表 1-1 Student 表结构列名 说明 数据类型 约束Sno 学号 字符串,长度为 7 主码Sname 姓名 字符串,长度为 10 非空Ssex 性别 字符串,长度为 2 取男或女Sage 年龄 整数 取值 1545Sdept 所在系 字符串,长度为 20 默认为计算机系表 3-1 Student 表数据Sno Sname Ssex SageSdept9512101 李勇 男 19 计算机系9512102 刘晨 男 20 计算机系9512103 王敏 女 20 计算机系9521101 张立 男 22 信息系9521102 吴宾 女 21 信息系9521103

2、张海 男 20 信息系9531101 钱小平 女 18 数学系9531102 王大力 男 19 数学系-表 1-2Course 表结构列名 说明 数据类型 约束Cno 课程号 字符串,长度为 10 主码Cname 课程名 字符串,长度为 20 非空Ccredit 学分 整数 取值大于 0Semster 学期 整数 取值大于 0Period 学时 整数 取值大于 0表 3-2 Course 表数据Cno Cname Ccredit SemesterC01 计算机文化学 3 1C02 VB 2 3C03 计算机网络 4 7C04 数据库基础 6 6C05 高等数学 8 2C06 数据结构 5 4表

3、 1-3 SC 表结构列名 说明 数据类型 约束Sno 学号 字符串,长度为 7 主码,引用 Student 的外码Cno 课程名 字符串,长度为 10 主码,引用 CourseGrade 成绩 整数 取值 0100表 3-3 SC 表数据Sno Cno Grade XKLB9512101 c01 90 必修9512101 c02 86 选修9512101 c06 必修9512102 c02 78 选修9512102 c04 66 必修9521102 c01 82 选修9521102 c02 75 选修9521102 c04 92 必修9521102 c05 50 必修9521103 c02

4、68 选修9521103 c06 必修9531101 c01 80 选修9531101 c05 95 必修9531102 c05 85 必修题 1:查询没有选修课程“c01”的学生姓名和所在系。答案:select sname,sdept from student where sno not in (select sno from sc where cno=C01)select sname,sdept from student,sc where (student.sno=sc.sno) and (sc.sno != “co1”)题 2:为 SC 表添加 “选课类别”列,此列的定义为 XKLB c

5、har(4)。答案:alter table sc add(XKLB varchar2(4);题 3:将新添加的 XKLB 的类型改为 char(6)。答案:alter table sc modify(XKLB varchar2 (6);题 4:删除 Course 表的 Period 列。答案:alter table course drop column period;题 5:删除计算机系不及格学生的选课记录。答案:delete from sc where grade=20 and sage 23;题 17:查询信息系,数学系和计算机系学生的姓名和性别。答案:select sname,ssex

6、from student where sdept IN (信息系 , 数学系 , 计算机系);题 18:查询既不属于信息系,数学系,也不属于计算机系的学生的姓名和性别。答案:select sname,ssex from student where sdept not in( 信息系,数学系,数学系);题 19:查询姓“张”的学生的详细信息。答案:select * from student where sname like 张%;题 20:查询学生表中姓“张” ,姓“李”和姓“刘”的学生的情况。答案:select * from student where sname like 张% or sna

7、me like 李% or sname like 刘%;或者select * from student where sname like 张李刘%; /错误题 21:查询名字中第 2 个字为“小”或“大”字的学生的姓名和学号。答案:select sname ,sno from student where sname like _小% or sname like _大%;或者select sname ,sno from student where sname like _小大 %;题 22:查询所有不姓“刘”的学生。答案:select * from student where sname not

8、 like 刘%;题 23:从学生表中查询学号的最后一位不是 2,3 ,5 的学生的情况。答案:select * from student where sno not like %2 and sno not like %3 and sno not like %5;或者select * from student where sno not like %235; /错误题 24:查询无考试成绩的学生的学号和相应的课程号。答案:select sno,cno from sc where grade is null;题 25:查询所有有考试成绩的学生的学号和课程号。答案:select sno,cno f

9、rom sc where grade is not null;题 26:查询计算机系年龄在 20 岁以下的学生的姓名。答案:select sname from student where sdept = 计算机系 and sage 3;题 38:查询选课门数等于或大于 4 门的学生的平均成绩和选课门数。答案:select sno,avg(Grade),count(*) from sc group by sno having count(*)= 4;题 39:查询每个学生的情况及其选课的情况。答案:select student.sno,sname,ssex,sage,o,cn.grade fro

10、m student , sc where student.sno=sc.sno;题 40:去掉例 38 中的重复列。答案:select distinct avg(grade),count(sno) 选课门数 from sc group by sno having count(sno)3;题 41:查询计算机系学生的选课情况,要求列出学生的名字,所修课的课程号和成绩。答案:select student.sname,o,sc.grade from sc left join student on student.sno=sc.sno where sc.sdept=计算机系;题 42:查询信息系选修

11、VB 课程的学生的成绩,要求列出学生姓名,课程名和成绩。答案:select student.sname,o,sc.grade from student join sc on student.sno=sc.sno join course on o=o where sc.sdept=信息系 and ame=VB;题 43:查询所有选修了 VB 课程的学生的情况,要求列出学生姓名和所在的系。答案:select student.sname,sc.sdept from student join sc on student.sno=sc.sno join course on o=o where ame=V

12、B;题 44:查询与刘晨在同一个系学习的学生的姓名和所在系。答案:select s2.sname, s2.sdept from student s1 , student s2 where s1.dept = s2.dept and s1.sname = 刘晨 and s2.sname != 刘晨;题 45:查询学生的选课情况,包括选修课程的学生和没有修课的学生。答案:select * from student left join sc on student.sno=sc.sno;题 46:查询与刘晨在同一个系的学生。答案:select sno,sname from student st1, s

13、tudent st2 where st1.sno = st2.sno and st2.sname=刘晨;题 47:查询成绩大于 90 分的学生的学号和姓名。答案:select sno,sname,grade from student,sc where grade in (select grade from sc where grade90)题 48:查询选修了“数据库基础”课程的学生的学号和姓名。答案:select sno,sname from student where sno in (select sno from sc where cno in (select cno from course where cname=数据库基础 )题 49:查询选修了课程“c02 ”且成绩高于次课程的平均成绩的学生的学号和成绩。答案:select sno,grade from sc where grade ( select AVG(grade) from sc where cno=C02 group by cno)题 50:查询选修了课程“c01 ”的学生姓名。答案:select sname from student where sno in (select sno from sc where cno=C01)

Copyright © 2018-2021 Wenke99.com All rights reserved

工信部备案号浙ICP备20026746号-2  

公安局备案号:浙公网安备33038302330469号

本站为C2C交文档易平台,即用户上传的文档直接卖给下载用户,本站只是网络服务中间平台,所有原创文档下载所得归上传人所有,若您发现上传作品侵犯了您的权利,请立刻联系网站客服并提供证据,平台将在3个工作日内予以改正。