SQLServer--使用T-SQL语句建立视图、删除视图、查看视图

使用T-SQL语句操做视图

提示:只能查看,删除,建立视图,不能对数据进行增,删,改操做。web

这里写图片描述

use StuManageDB
go
--判断视图是否存在
if exists(Select * from sysobjects where Name='View_ScoreQuery') drop view View_ScoreQuery go --建立视图 create view View_ScoreQuery as select Students.StudentId,StudentName,ClassName,C#=CSharp,SQLDB=SqlServerDB, ScoreSum=(CSharp+SQLServerDB) from Students inner join ScoreList on Students.StudentId=ScoreList.StudentId inner join StudentClass on Students.ClassId = StudentClass.ClassId go select * from View_ScoreQuery 

这里写图片描述

视图能够嵌套另一个视图(尽可能少套用)。sql