Name for SELECT * FROM (VALUES (x,y)) AS TableLiteral(Col1, Col2)

烂漫一生 提交于 2019-12-12 10:38:18

问题


The following is valid SQL syntax:

SELECT *
    FROM (VALUES ('p','q'),('x','y')) AS TableLiteral(Col1, Col2)

and returns the table:

  | Col1 | Col2
----------------
1 |  p   |  q
2 |  x   |  y

This syntax can further be used in CTEs etc.

Is there a name for this? I've been calling them "TableLiterals" by analogy with string literals and regex literals.

Is there a term that will be widely recognised.


回答1:


It is called: Table Value Constructor

Specifies a set of row value expressions to be constructed into a table. The Transact-SQL table value constructor allows multiple rows of data to be specified in a single DML statement. The table value constructor can be specified in the VALUES clause of the INSERT statement, in the USING clause of the MERGE statement, and in the definition of a derived table in the FROM clause.

VALUES ( ) [ ,...n ]

More info about ANSI standard: F641, Row and table constructors and select without from




回答2:


They are called Table Value constructor

https://docs.microsoft.com/en-us/sql/t-sql/queries/table-value-constructor-transact-sql



来源:https://stackoverflow.com/questions/45466558/name-for-select-from-values-x-y-as-tableliteralcol1-col2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!