Search code examples
postgresqljsonb

how insert a new value in a jsonb postgresql array of integer


I have in my table a column with type jsonb with this value

'[2,4]' 

how can I update my table to insert one or more values in this column?

tks


Solution

  • Use the || operator

    select '[2,4]'::jsonb || '[5,6]';
       ?column?   
    --------------
     [2, 4, 5, 6]