SQL – transaction

mysql / mariadb

START TRANSACTION;
SELECT @A:=SUM(salary) FROM table1 WHERE type=1;
UPDATE table2 SET summary=@A WHERE type=1;
COMMIT; (ROLLBACK;)

postgres

BEGIN;
UPDATE accounts SET balance = balance - 100.00
    WHERE name = 'Alice';
COMMIT; (ROLLBACK;)

sqlserver

BEGIN TRANSACTION
UPDATE Customers
SET Country = 'UKA'
WHERE Country = 'UK'
COMMIT; (ROLLBACK;)
タイトルとURLをコピーしました