ROW() constructor
PG 7.4+→ recordConstructs an anonymous composite (row) value from a list of field values. ROW keyword is optional when there are multiple fields.
Signature
ROW ( expression [, expression ...] ) → recordParameters
| Parameter | Type | Description |
|---|---|---|
| expression | any | Field values for the row |
Examples
SELECT ROW(1, 'Alice', true);(1,Alice,t)SELECT (1, 'hello', now()) AS my_row;(1,hello,2025-03-07...)SELECT ROW(id, name) FROM users LIMIT 3;Row values as composite recordsSELECT * FROM orders WHERE (year, month) IN ((2024, 12), (2025, 1), (2025, 2));Orders in specified year-month pairsINSERT INTO archive SELECT ROW(id, status, updated_at) FROM jobs WHERE done;Composite rows inserted into archiveYou can compare row constructors: `(col1, col2) = (val1, val2)` is equivalent to `col1 = val1 AND col2 = val2` but more concise. Also useful for multi-column IN checks: `(a,b) IN ((1,2),(3,4))`.
SELECT * FROM orders WHERE (year, month) IN ((2024, 12), (2025, 1), (2025, 2));Orders in specific year-month combinations