如批量更新采购订单行sequence字段,按照订单行id的顺序赋值1,2,3,4...:
UPDATE purchase_order_line_copy1
SET sequence = subquery.new_sequence
FROM (SELECT id, ROW_NUMBER() OVER (ORDER BY id) AS new_sequenceFROM purchase_order_lineWHERE order_id = 748
) AS subquery
WHERE purchase_order_line_copy1.id = subquery.id
and purchase_order_line_copy1.order_id = 748
限制订单为748的订单行,更新订单行sequence字段,效果如下: