select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

FUNCTIONS / ARRAY FUNCTIONS AND OPERATORS

Trims an array by removing the last n elements.

Signatures & examples

trim_array ( array anyarray, n integer ) → anyarray
Trims an array by removing the last n elements. If the array is multidimensional, only the first dimension is trimmed.
trim_array(ARRAY[1,2,3,4,5,6], 2) → {1,2,3,4}
Version history 1
  1. PG 13 → 14added

Definition snapshot: 2026-09-14T13:14:25.684213+00:00@99e6866c · English manual source