Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove array values in pgSQL

Is there a way to remove a value from an array in pgSQL? Or to be more precise, to pop the last value? Judging by this list the answer seems to be no. I can get the result I want with an additional index pointer, but it's a bit cumbersome.

like image 629
oggy Avatar asked Jan 15 '10 15:01

oggy


1 Answers

In version 9.3 and above you can do:

update users set flags = array_remove(flags, 'active') 
like image 103
John Sheehan Avatar answered Oct 12 '22 22:10

John Sheehan