码迷,mamicode.com
首页 > 数据库 > 详细

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

时间:2015-04-28 11:24:34      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:

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

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当作一个临时表来用,就是子查询

技术分享

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

标签:

原文地址:http://www.cnblogs.com/dlexia/p/4462129.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!