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

2021/7/27 19:35:49

本文主要是介绍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;

 



这篇关于037.PGSQL-事务 savepoint 保存点、rollback to 回滚的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程