VALUES statement

Synopsis

VALUES row [, ...]

where row is a single expression or

( column_expression [, ...] )

Syntax diagram

Read syntax diagramSkip visual syntax diagram VALUESrow ,
Read syntax diagramSkip visual syntax diagram(, column_expression)

For information on reading syntax diagrams, see How to read syntax diagrams

Description

Defines a literal inline table.

VALUES can be used anywhere a query can be used (e.g., the FROM clause of a SELECT statement, an INSERT statement, or even at the top level). VALUES creates an anonymous table without column names, but the table and columns can be named using an AS clause with column aliases.

Examples

Return a table with one column and three rows:
VALUES 1, 2, 3
Return a table with two columns and three rows:
VALUES
    (1, 'a'),
    (2, 'b'),
    (3, 'c')
Return table with column id and name:
SELECT * FROM (
    VALUES
        (1, 'a'),
        (2, 'b'),
        (3, 'c')
) AS t (id, name)
Create a new table with column id and name:
CREATE TABLE example AS
SELECT * FROM (
    VALUES
        (1, 'a'),
        (2, 'b'),
        (3, 'c')
) AS t (id, name)