Skip to content

Instantly share code, notes, and snippets.

@emafriedrich
Created June 22, 2024 11:28
Show Gist options
  • Save emafriedrich/666c968335135a1a44a3c09b3a0d98cb to your computer and use it in GitHub Desktop.
Save emafriedrich/666c968335135a1a44a3c09b3a0d98cb to your computer and use it in GitHub Desktop.
Select random array element PostgreSQL
update table set your_colum = (array['foo', 'bar', 'baz'])[floor(random() * 3 + 1)]; -- replace 3 with your array length
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment