1.create view v_student
as
select dbo.Person.PID , dbo.Person.PCID, dbo.Person.PType, dbo.Person.PLoginName,
dbo.Person.PCName, dbo.Person.PPYName, dbo.Person.PPwd, dbo.Person.PGender, dbo.Person.PEmail,
dbo.Person.PAreas, dbo.Person.PIsDel, dbo.Person.PAddTime, dbo.Classes.CName
from
Person ,Classes where Person.PCID=Classes.CID
总结: select后面的项来自不同的表 但是在where中要有他们连接的方式和条件。
2.create view v_score1
As
Select s.sno,s.sname,c.cname,sc.score
From s,c,sc
Where s.sno=sc.sno and c.cno=sc.cno and sno=“20030001”
通用的检查是否存在:
CREATE VIEW view_name
AS
<select语句>
IF EXISTS (SELECT * FROM sysobjects WHERE /*检测是否存在*/
name = 'view_stuInfo_stuMarks')
DROP VIEW view_stuInfo_stuMarks /*删除视图*/
GO
CREATE VIEW view_stuInfo_stuMarks /*创建视图*/