↑↓ select↵ open⌫ change scopeOpen full search

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

Wiki / Functions

array_sample

Returns an array of n items randomly selected from array. n may not exceed the length of array's first dimension. If array is multi-dimensional, an “item” is a slice having a given first subscript.

English manual coverage begins with PostgreSQL 7.1. Source history and runtime observations have their own recorded version boundaries.

Reading PG 18·Select a recorded version

group
array
group label
Array Functions And Operators
lang
en
layout
table-new
pages
functions-array.html
prose only
false

Definition PG 18

Returns an array of n items randomly selected from array. n may not exceed the length of array's first dimension. If array is multi-dimensional, an “item” is a slice having a given first subscript.

Signatures and overloads

array_sample ( array anyarray, n integer ) → anyarray → anyarray
Returns an array of n items randomly selected from array. n may not exceed the length of array's first dimension. If array is multi-dimensional, an “item” is a slice having a given first subscript.

Compare versions

Source references

Full definition and evidence JSON

Definition sources

center · PostgreSQL 18 · wiki-repair-20261023:d2d34a7b6e69d717e43fdd689803c9a55200d492142fd5cda5cd8db5abf84e86

Text language: en · wiki-repair-20261023:d2d34a7b6e69d717e43fdd689803c9a55200d492142fd5cda5cd8db5abf84e86