T-SQL - 什么是内联视图?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/829354/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 01:57:18  来源:igfitidea点击:

T-SQL - What is an inline-view?

sqltsql

提问by Robin Day

I recently answered this question how-to-call-user-defined-function-in-order-to-use-with-select-group-by-order-by

我最近回答了这个问题how-to-call-user-defined-function-in-order-to-use-with-select-group-by-order-by

My answer was to use an inline view to perform the function and then group on that.

我的答案是使用内联视图来执行该功能,然后对其进行分组。

In comments the asker has not understood my response and has asked for some sites / references to help explain it.

在评论中,提问者没有理解我的回答,并要求提供一些网站/参考资料来帮助解释。

I've done a quick google and haven't found any great resources that explain in detail what an inline view is and where they are useful.

我已经做了一个快速的谷歌,但没有找到任何很好的资源来详细解释内联视图是什么以及它们在哪里有用。

Does anyone have anything that can help to explain what an inline view is?

有没有人可以帮助解释内联视图是什么?

回答by Otávio Décio

From here: An inline view is a SELECT statement in the FROM-clause of another SELECT statement. In-line views are commonly used simplify complex queries by removing join operations and condensing several separate queries into a single query.

这里:内联视图是另一个 SELECT 语句的 FROM 子句中的 SELECT 语句。内嵌视图通常用于通过删除连接操作并将多个单独的查询压缩为单个查询来简化复杂的查询。

回答by JDU

I think another term (possibly a SQL Server term) is 'derived table'

我认为另一个术语(可能是 SQL Server 术语)是“派生表”

For instance, this article:

比如这篇文章:

http://www.mssqltips.com/tip.asp?tip=1042

http://www.mssqltips.com/tip.asp?tip=1042

or

或者

http://www.sqlteam.com/article/using-derived-tables-to-calculate-aggregate-values

http://www.sqlteam.com/article/using-derived-tables-to-calculate-aggregate-values

回答by Tomalak

IMHO, an "inline view" is just another expression for a row-returning sub-query.

恕我直言,“内联视图”只是行返回子查询的另一个表达式。

In other words — an SQL expression that could be replaced entirely by the name of a view (therefore, a correlated sub-query does not qualify as an inline view).

换句话说——一个可以完全由视图名称替换的 SQL 表达式(因此,相关子查询不符合内联视图的条件)。

回答by ahains

This MSDN articleclaims that an inline view is another term for a derived table, and refers to the same thing everyone else is describing in this thread (subquery in FROM). An alternative in sql server 2005 and up is the common table expression.

这篇MSDN 文章声称内联视图是派生表的另一个术语,指的是其他人在此线程中描述的相同内容(FROM 中的子查询)。sql server 2005 及更高版本中的另一种选择是公用表表达式。

回答by northpole

Another term often more commonly used for an inline view is 'Embedded Select Statement'

内联视图更常用的另一个术语是“嵌入式选择语句”

So a select inside a select.

所以选择里面的选择。

回答by Imran M.

An inline view is a virtual tablecreated in the from statement during the execution of the code/program

内联视图是在代码/程序执行期间在 from 语句中创建的虚拟表