Very often in practice I have to do a bulk update of rows.
IN PostgreSQL:
UPDATE table AS t
SET
col1 = c.col1,
col2 = c.col2
FROM (VALUES (1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4) ) AS c (id, col1, col2)
WHERE c.id = t.id;
or
INSERT INTO table (id, col1, col2)
VALUES (1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4)
ON CONFLICT (id) DO UPDATE SET
col1 = EXCLUDED.col1,
col2 = EXCLUDED.col2
IN MySQL:
INSERT INTO table (id, col1, col2)
VALUES (1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4)
ON DUPLICATE KEY UPDATE
col1 = VALUES(col1),
col2 = VALUES(col2);
I'm sure other databases have similar capabilities.
For each DBMS will have its own specific implementation of the method batchUpdate in descendant classes.
Sorry for my bad english.
Very often in practice I have to do a bulk update of rows.
IN PostgreSQL:
or
IN MySQL:
I'm sure other databases have similar capabilities.
For each DBMS will have its own specific implementation of the method batchUpdate in descendant classes.
Sorry for my bad english.