数据库
首页 > 数据库> > 037.PGSQL-事务 savepoint 保存点、rollback to 回滚

037.PGSQL-事务 savepoint 保存点、rollback to 回滚

作者:互联网

事务

savepoint 保存点

rollback to 回滚

 

开启一个事务需要将SQL命令用BEGINCOMMIT命令包围起来

BEGIN;
UPDATE accounts SET balance = balance - 100.00
    WHERE name = 'Alice';
SAVEPOINT my_savepoint;
UPDATE accounts SET balance = balance + 100.00
    WHERE name = 'Bob';
-- oops ... forget that and use Wally's account
ROLLBACK TO my_savepoint;
UPDATE accounts SET balance = balance + 100.00
    WHERE name = 'Wally';
COMMIT;

 

标签:SET,rollback,savepoint,UPDATE,PGSQL,accounts,balance,WHERE
来源: https://www.cnblogs.com/star521/p/15067525.html