Skip to content
masterclass Buddy

PostgreSQL · Function

unnest

PostgreSQL's unnest function expands array elements into rows. It can also expand multiple arrays together and optionally add row numbers.

Last updated

Syntax

unnest(anyarray) → setof anyelement
unnest(anyarray, anyarray [, ...]) → setof anyelement, anyelement [, ...]

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • array_agg
  • WITH ORDINALITY
  • ROWS FROM

Source: PostgreSQL: Documentation: 18: 9.19. Array Functions and Operators. Checked 2026-11-03.