Przykład:zamień numer_dokumentu na identyfikatory 2 i 4:
UPDATE tbl dst
SET doc_num = src.doc_num
FROM tbl src
WHERE dst.id IN(2,4)
AND src.id IN(2,4)
AND dst.id <> src.id -- don't try this at home!
;
SELECT * FROm tbl
ORDER BY id;
Wynik:
id | doc_num | doc_text
----+---------+--------------------
1 | 1 | First column text1
2 | 3 | First column text2
4 | 2 | First column text3
7 | 4 | First column text4
(4 rows)