Inline Table

Description

An inline table is a temporary table created using a VALUES clause.

Syntax

  1. VALUES ( expression [ , ... ] ) [ table_alias ]

Parameters

  • expression

    Specifies a combination of one or more values, operators and SQL functions that results in a value.

  • table_alias

    Specifies a temporary name with an optional column name list.

    Syntax: [ AS ] table_name [ ( column_name [ , ... ] ) ]

Examples

  1. -- single row, without a table alias
  2. SELECT * FROM VALUES ("one", 1);
  3. +----+----+
  4. |col1|col2|
  5. +----+----+
  6. | one| 1|
  7. +----+----+
  8. -- three rows with a table alias
  9. SELECT * FROM VALUES ("one", 1), ("two", 2), ("three", null) AS data(a, b);
  10. +-----+----+
  11. | a| b|
  12. +-----+----+
  13. | one| 1|
  14. | two| 2|
  15. |three|null|
  16. +-----+----+
  17. -- complex types with a table alias
  18. SELECT * FROM VALUES ("one", array(0, 1)), ("two", array(2, 3)) AS data(a, b);
  19. +---+------+
  20. | a| b|
  21. +---+------+
  22. |one|[0, 1]|
  23. |two|[2, 3]|
  24. +---+------+