Created
June 22, 2024 11:28
-
-
Save emafriedrich/666c968335135a1a44a3c09b3a0d98cb to your computer and use it in GitHub Desktop.
Select random array element PostgreSQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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