是否可以使用从另一个索引视图中选择的SQL Server 2008创建索引视图?

时间:2021-01-31 10:21:12

Is it possible to create an indexed view with SQL Server 2008 which selects from another indexed view?

是否可以使用从另一个索引视图中选择的SQL Server 2008创建索引视图?

create view V1 as (select 1 as abc)
create view V2 as (select abc from V1 group by abc)

2 个解决方案

#1


I think the answer is "no, it is not possible".

我认为答案是“不,这是不可能的”。

From Microsoft TechNet Site, in an article about performance:

从Microsoft TechNet站点,在有关性能的文章中:

Q. I have a view defined on top of another view. SQL Server won't let me index the top-level view. What can I do?

问:我在另一个视图之上定义了一个视图。 SQL Server不会让我索引*视图。我能做什么?

A. Consider expanding the definition of the nested view by hand into the top-level view, and then indexing it, indexing the innermost view, or not indexing the view.

A.考虑手动将嵌套视图的定义扩展到*视图,然后对其进行索引,索引最内层视图或不索引视图。

Good Luck.

#2


Here are the requirements for indexed views (they are plentiful):

以下是索引视图的要求(它们很多):

  • The view must reference only base tables in the same database, not other views.
  • 视图必须仅引用同一数据库中的基表,而不引用其他视图。

#1


I think the answer is "no, it is not possible".

我认为答案是“不,这是不可能的”。

From Microsoft TechNet Site, in an article about performance:

从Microsoft TechNet站点,在有关性能的文章中:

Q. I have a view defined on top of another view. SQL Server won't let me index the top-level view. What can I do?

问:我在另一个视图之上定义了一个视图。 SQL Server不会让我索引*视图。我能做什么?

A. Consider expanding the definition of the nested view by hand into the top-level view, and then indexing it, indexing the innermost view, or not indexing the view.

A.考虑手动将嵌套视图的定义扩展到*视图,然后对其进行索引,索引最内层视图或不索引视图。

Good Luck.

#2


Here are the requirements for indexed views (they are plentiful):

以下是索引视图的要求(它们很多):

  • The view must reference only base tables in the same database, not other views.
  • 视图必须仅引用同一数据库中的基表,而不引用其他视图。