数据库视图--学生教师信息表为例

--视图,视图就是一个虚拟的表,只能查询,不能修改!只能用作查询!

select *from View_1 

--显示101这个学生的学生sno,sname,cno,degree
create view view 2
as
   select Student.Sno,sname,cno,DEGREE from Student join Score on Student.Sno=Score.Sno
go


select Student.Sno,sname,cno,DEGREE from Student join Score on Student.Sno=Score.Sno
select *from View_2 where Sno=101--视图view_2里面只选择sno,sname,cno,degree


select *from(select Student.Sno,sname,cno,DEGREE from Student join Score on Student.Sno=Score.Sno) as table2 where Sno=101
--select Student.Sno,sname,cno,DEGREE from Student join Score on Student.Sno=Score.Sno当作一个临时表来用,就是子查询

posted @ 2015-04-28 09:38  Yusarin  阅读(633)  评论(0编辑  收藏  举报