数据库中创建视图

视图   :有联系的表之间,建立虚拟的表!

步骤  :打开数据库中  ‘选用的数据库’,右击‘视图’,选择‘新建视图’。然后填加  

‘选用的数据库’中有关联的  ‘表’,选择视图中 要显示的 ‘列’,然后关闭,保存新视图就创建完成!

--drop view       xueshengfenshu   --删除视图

--alter view     xkf                 --修改视图就是删除重写!

只有在前面使用top数字后,才可以使用 order by 。视图中不能使用聚合函数

create view xueshengfenshu

as

select student.sno,sname,ssex,sbirthday,class,score.Cno,Degree from student

join  score on student.sno=score.Sno这是完整的创建视图语句!

select *from xueshengfenshu

   --学生.课程,分数三个表的视图!

create view xkf

as

select student.sno,sname,ssex,sbirthday,class,score.Cno,Degree,course.Cname from student

join score on student.sno=score.Sno

join course on course.Cno=score.Cno

select *from xkf

原文地址:https://www.cnblogs.com/huaze/p/4087547.html