云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 数据库实验1-6参考答案

数据库实验1-6参考答案

  • 62 次阅读
  • 3 次下载
  • 2025/5/1 16:31:11

(3)工程项目表J: JNO J1 J2 J3 JNAME 一汽 半导体厂 CITY 北京 南京 常州

第三条记录是否能够正常输入,若否,会出现什么问题,为什么? 第三条记录不能输入,因为JNAME不能取NULL值。

(4)供应情况表SPJ: SN0 S1 S1 S2 PNO P1 P1 P2 JNO J1 J3 J4 QTY 200

输入过程中是否会遇到问题,若有,出在哪,为什么?

第三条记录不能输入,因为在工程项目表J中没有J3,破坏了参考完整性。

四、实验小结

五、评阅成绩

实验预习20% 实验过程20% 实验结果30% 实验报告30% 总成绩 9

实验三 数据查询

一、实验目的

1、掌握查询语句的基本组成和使用方法 2、掌握常用查询技巧

二、实验预习

1、SQL中查询语句格式:

2、连接查询有哪些不同的连接方式?有什么特点。

三、实验内容和要求

1、按照下表中的内容,在企业管理器中为数据库表输入相应的数据。 学生表:Student Sno 9512101 9512103 9521101 9521102 9521103 9531101 9531102 Cno C01 C02 C03 C04 C05

Sname 李勇 王敏 张莉 吴宾 张海 钱小平 王大力 Cname 计算机导论 VB 计算机网络 数据库基础 高等数学 Ssex 男 女 女 男 男 女 男 Ccredit 3 4 4 6 8 10

Sage 19 20 22 21 20 18 19 Semster 1 3 7 6 1 Sdept 计算机系 计算机系 信息系 信息系 信息系 数学系 数学系 Period 3 4 4 4 8 课程表:Course 选课表:SC Sno 9512101 9512103 9512101 9512103 9521101 9521102 9521103 9531101 9531102 9512101 9531102 9512101 9512101 Cno C03 C03 C05 C05 C05 C05 C05 C05 C05 C01 C01 C02 C04 Grade 95 51 80 60 72 80 45 81 94 NULL NULL 87 76

2、完成下列查询

(1)查询全体学生的信息。

select * from student

(2)查询“信息系”学生的学号,姓名和出生年份。

select Sno,Sname,2009-Sage as Birthyear from student where Sdept='信息系'

(3)查询考试不及格的学生的学号。

select Distinct Sno from SC where Grade<60

(4)查询无考试成绩的学生的学号和相应的课程号。

select Sno,Cno from SC where Grade is null

(5)将学生按年龄升序排序。

select * from student order by Sage asc

(6)查询选修了课程的学生的学号和姓名。

11

Select Sno,Sname from Student Where Sno in (Select Sno From Sc) 或:

select distinct student.Sno,Sname from student,SC where student.Sno=SC.Sno

(7)查询年龄在20-23岁之间的学生的姓名,系,年龄。

select Sname,Sage,Sdept from student where Sage between 20 and 23

(8)查询同时选修了“计算机导论”,“高等数学”课程的学生的学号,姓名。

select student.Sno,Sname from student where NOT EXISTS( select* from course where

Cname in('高等数学','计算机导论') AND NOT EXISTS(select * from SC where Sno=student.Sno and Cno=course.Cno)) 或:

select student.Sno,Sname from student,sc,Course where student.sno=sc.sno and sc.cno=course.cno and cname='高等数学' and student.sno in (select sno from sc where cno=(select cno from course where cname='计算机导论')) 或:

select student.Sno,Sname from student where sno in (select sno from sc where cno=(select cno from course where cname='高等数学')) and sno in (select sno from sc where cno=(select cno from course where cname='计算机导论'))

(9)查询姓“张”的学生的基本信息。

select * from student where Sname like '张%'

(10)查询“95211”班学生的选课情况,要求输出学号,姓名,课程名,成绩,按照学号升序排序。

select student.Sno,Sname,Cname,Grade from student,SC,course where student.Sno=SC.Sno and course.Cno=SC.Cno

and student.Sno like '95211%' order by student.Sno 或:

select student.Sno,Sname,Cname,Grade from student,SC,course where student.Sno=SC.Sno and course.Cno=SC.Cno

and left(student.sno,5)= '95211' order by 1

(11)查询选修了课程的学生的总人数。

12

搜索更多关于: 数据库实验1-6参考答案 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

(3)工程项目表J: JNO J1 J2 J3 JNAME 一汽 半导体厂 CITY 北京 南京 常州 第三条记录是否能够正常输入,若否,会出现什么问题,为什么? 第三条记录不能输入,因为JNAME不能取NULL值。 (4)供应情况表SPJ: SN0 S1 S1 S2 PNO P1 P1 P2 JNO J1 J3 J4 QTY 200 输入过程中是否会遇到问题,若有,出在哪,为什么? 第三条记录不能输入,因为在工程项目表J中没有J3,破坏了参考完整性。 四、实验小结 五、评阅成绩 实验预习20% 实验过程20% 实验结果30% 实验报告30% 总成绩 9 实验三 数据查询 一、实验目的 1

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com