多行多次更新与许多更新语句的工作原理完全相同吗? [PostgreSQL的]

时间:2017-09-13 21:03:09

标签: sql postgresql transactions sql-update

我似乎无法找到解决此问题的任何资源,

UPDATE "my-table" AS t 
   SET "val"=v."val",
        "msg"=v."msg" 
FROM (
   VALUES(1,123,'hello'),
         (2,456,'world!')
) AS v("id","val","msg") 
WHERE v.id = t.id

VS

UPDATE "my-table" 
    SET val = 123, msg = 'hello' 
WHERE id = 1;

UPDATE "my-table" 
    SET val = 456, msg = 'world' 
WHERE id = 2;

我感兴趣的是读取提交隔离级别的每种情况之间的并发控制是否相同?

阅读完本文后,我对它如何同时处理UPDATE感到非常安全https://www.postgresql.org/docs/current/static/transaction-iso.html#XACT-READ-COMMITTED

BEGIN;
UPDATE accounts SET balance = balance + 100.00 WHERE acctnum = 12345;
UPDATE accounts SET balance = balance - 100.00 WHERE acctnum = 7534;
COMMIT;

但是没有提及多值更新及其行为方式?

0 个答案:

没有答案