內嵌式表格
說明
內嵌式表格是使用 VALUES 子句建立的暫時表格。
語法
VALUES ( expression [ , ... ] ) [ table_alias ]
參數
-
運算式
指定一個或多個值、運算子與 SQL 函數的組合,其結果為一個值。
-
表格別名
指定一個暫時名稱,並可選擇指定一個欄位名稱清單。
語法:
[ AS ] table_name [ ( column_name [ , ... ] ) ]
範例
-- single row, without a table alias
SELECT * FROM VALUES ("one", 1);
+----+----+
|col1|col2|
+----+----+
| one| 1|
+----+----+
-- three rows with a table alias
SELECT * FROM VALUES ("one", 1), ("two", 2), ("three", null) AS data(a, b);
+-----+----+
| a| b|
+-----+----+
| one| 1|
| two| 2|
|three|null|
+-----+----+
-- complex types with a table alias
SELECT * FROM VALUES ("one", array(0, 1)), ("two", array(2, 3)) AS data(a, b);
+---+------+
| a| b|
+---+------+
|one|[0, 1]|
|two|[2, 3]|
+---+------+