SQL综合练习题
学生表:Student(Sno,Sname,Ssex,Sage,Sdept) Sno为主码;
说明:Sno 学号 Sname姓名,Ssex 性别,Sage 年龄。Sdept所在系
课程表:Course(Cno,Cname,Cpno,Credeit) Cno为主码;
说明:Cno课程号,Cname 课程名,Cpno 先行课,Credit学分
学生选修表:SC(Sno,Cno,Grade) Sno,Cno,为主键;
说明:Sno 学号,Cno课程号,Grade成绩
用SQL脚本完成以下功能:
1、查询所在系为CS或IS的学生的姓名和学号
select sname,sno from Student
where sdept = 'IS' OR sdept = 'CS'
2、查询全体课程信息
select Cname from Course
3、查询所有姓王或刘的同学的全部信息
select * from sc,course,student
where sc.cno=course.cno and student.sno=sc.sno
and (sname like '王%' or sname like '刘%')
4、查询年龄在20-25之间的女学生的信息
select * from student
where sage between 20 and 25 and ssex='女'
5、查询按学号升序排列的前10名的学生信息
select top 10 * from student order by sno asc
评论0