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

xiaoxiao2021-02-28  121

使用T-SQL语句操作视图

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

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

视图可以嵌套另外一个视图(尽量少套用)。


转载请注明原文地址: https://www.6miu.com/read-18061.html

最新回复(0)