- 对视图创建唯一索引后,视图的结果集将存储在数据库中,就像带有聚集索引的表一样。建有唯一聚集索引的视图称为索引视图,也称为物化视图
- 定义视图
select * from c
select * from d
1 --定义视图 2 create view dbo.vc 3 with schemabinding 4 as 5 select c1 * c2 * (2 + d1 - d2) as ccc 6 from dbo.c , dbo.d 7 where dbo.c.c1 = dbo.d.d1 8 go 9 --在视图上定义一个唯一聚集索引 10 create unique clustered index view_index 11 on dbo.vc(ccc)
- 查询视图
select * from dbo.vc