数据库实验五题目答案.pdfVIP

  • 10
  • 0
  • 约6.19千字
  • 约 11页
  • 2020-09-07 发布于天津
  • 举报
. 实验五 实验 5.1 数据查询 1) 要求 以 School 数据库为例,在该数据库中存在四张表格,分别为: 表 STUDENTS(sid, sname, email, grade); 表 TEACHERS(tid, tname, email, salary); 表 COURSES(cid, cname, hour); 表 CHOICES(no, sid, tid, cid, score) 在数据库中,存在这样的关系:学生可以选择课程,一个课程对应一个教师。在表 CHOICES 中保存学生的选课记录。 按以下要求对数据库进行查询操作: (1) 查询年级为 2001 的所有学生的名称并按编号升序排列。 程序 :Select sname from students where grade=2001 order by sid asc; (2) 查询学生的选课成绩合格的课程成绩。 程序: Select score from choices where score59; . . (3) 查询课时是 48 或 60 的课程的名称。 程序: select cname from courses where hour =48 or hour = 60 ; (4) 查询所有课程名称中含有 data 的课程编号。 程序: select cid from courses where cname like %data% ; . . (5) 查询所有选课记录的课程号(不重复显示) 。 程序: select distinct cid from choices ; (6) 统计所有教师的平均工资。 程序: select avg ( salary ) from teachers ; . . (7) 查询所有教师的编号及选修其课程的学生的平均成绩,按平均成绩降序排列。 程序: select tid , avg ( score ) from choices

文档评论(0)

1亿VIP精品文档

相关文档