学生成绩管理系统课程设计说明书 第4页

学生成绩管理系统课程设计说明书 第4页
查看记录
Select * from teacher
 
图15 教师信息查询图
5.3.5一些查询语句
(1)查询成绩大于学号为201的学生的课程为02的成绩的所有列。
select * from score where degree>(select degree from score where sno='201' and cno='02')
 
图16 成绩查询图
(2)查询课程号01大于课程号02的最大值、并以分数降序排序的成绩表中所有列
select * from score s where s.cno='01' and s.degree>=(select max(degree) from score y where y.cno='02' ) order by degree desc
go
 select max(degree) as "02max" from score where cno='02'
                                                         沈  阳  大  学             
课程设计说明书                 NO.13
 
                   图17 成绩查询图
(3)查询性别为男的学号,姓名,班级,课程号和成绩的学生
select student.sno,student.sname,student.class,score.cno,score.degree from student,score where
student.sno=score.sno and ssex='男'
 
                        图18  成绩查询图
(4)查询成绩在60到80之间的所有列
select * from score where degree between 60 and 80
 
                          图19 成绩查询图

                                                         沈  阳  大  学             
课程设计说明书                 NO.14
(4)查询成绩在男生70到90之间的所有列
select * from score,student where degree between 70 and 90 and ssex='男'and student.sno=score.sno
 
图20  成绩查询图
5.4 创建自定义数据类型
创建一个email自定义数据类型
 exec sp_addtype email, 'varchar(20)' , 'null'
修改student表中的semail数据类型为email类型
alter table student alter column semail email
5.5 向表中添加字段
  向student表添加type,semail,,b并且邮件地址有check约束
alter table student add type char(7)
alter table student add semail varchar(20) null constraint ck_sem check (semail like '%@%')
alter table teacher add tel varchar(15)
5.6 创建视图
5.6.1创建所有3班的学生信息的视图
create view student03
as
 select * from student where class='03'

上一页  [1] [2] [3] [4] [5] 下一页

Copyright © 2007-2012 www.chuibin.com 六维论文网 版权所有