本文介绍了将 INDEX 添加到 CTE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以将 INDEX 添加到公共表表达式 (CTE) 吗?
Can I add an INDEX to a Common Table Expression (CTE)?
推荐答案
没有
CTE 是一种临时的内联"视图 - 您不能向此类构造添加索引.
A CTE is a temporary, "inline" view - you cannot add an index to such a construct.
如果您需要索引,请使用 CTE 的 SELECT 创建一个常规视图,并使其成为索引视图(通过向视图添加聚集索引).您需要遵守此处列出的一组规则:创建索引视图.
If you need an index, create a regular view with the SELECT of your CTE, and make it an indexed view (by adding a clustered index to the view). You'll need to obey a set of rules outlined here: Creating an Indexed View.
这篇关于将 INDEX 添加到 CTE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!