sql >> Base de Datos >  >> RDS >> PostgreSQL

Postgres:modifica cada elemento de la matriz

Necesitas anular, dividir y luego volver a agregar.

update the_table
  set the_array = array(select t.val / 10 
                        from unnest(the_table.the_array) as t(val));

Si necesita conservar el orden original en la matriz, use with ordinality

update the_table
  set the_array = array(select t.val / 10 
                        from unnest(the_table.the_array) with ordinality as t(val,idx) 
                        order by t.idx);

Para ejecutar esto en Liquibase, debe usar un <sql> cambiar

Ejemplo en línea:https://rextester.com/IJGA96691