← All notes

PostgreSQL array columns and functions

Short answer

Any column can be a variable-length, multidimensional array of almost any type. Write literals as '{1,2,3}' or ARRAY[1,2,3]; arrays are one-based, so the first element is a[1]. [S1]

SELECT tags[1], array_length(tags, 1) FROM posts;
SELECT unnest(ARRAY['a','b']);          -- one row per element
UPDATE posts SET tags = array_append(tags, 'new');

[S2]

Gotchas

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: PostgreSQL Global Development Group, PostgreSQL: Documentation: 18: 8.15. Arrays, PostgreSQL License; PostgreSQL Global Development Group, PostgreSQL: Documentation: 18: 9.19. Array Functions and Operators, PostgreSQL License.

Cite this

Permanent ID: iil:note:wp1b93kn

iinventedlight. 2026. "PostgreSQL array columns and functions." iinventedlight Library, iil:note:wp1b93kn, version of 2026-11-04. https://iinventedlight.com/library/notes/postgres-arrays/. License: CC-BY-4.0.

@misc{iil_note_wp1b93kn,
  author = {{iinventedlight}},
  title = {{PostgreSQL array columns and functions}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-04},
  url = {https://iinventedlight.com/library/notes/postgres-arrays/},
  note = {Permanent ID iil:note:wp1b93kn. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.

For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/postgres-arrays.md.