SAVEPOINT
Sign in to saveA savepoint is a way of implementing subtransactions (also known as nested transactions) within a relational database management system by indicating a point within a transaction that can be "rolled back to" without affecting any work done in the transaction before the savepoint was created. Multiple savepoints can exist within a single transaction. Savepoints are useful for implementing complex error recovery in database applications. If an error occurs in the midst of a multiple-statement transaction, the application may be able to recover from the error (by rolling back to a savepoint) with
Article · 日本語
SAVEPOINTは、サブトランザクション(入れ子トランザクションとも呼ばれる)を実現するための、データベース言語SQLのステートメントの1つである。トランザクション内の特定の地点に名前を付け、その地点以前に行った処理に影響を及ぼすことなく、その地点以降に行った処理をロールバックできる。1つのトランザクション内で複数の SAVEPOINT を作成することもできる。 SAVEPOINTはデータベースを利用するアプリケーションで、複雑なエラー復帰処理を実現するのに有効である。複数のステートメントから成るトランザクションの途中でエラーが発生した場合、SAVEPOINTを利用すると、トランザクション全体をロールバックすることなく、エラーから復帰することができる。 SAVEPOINT の使用例を以下に示す。SAVEPOINT <i>name</i> で地点に名前を付け、ROLLBACK TO SAVEPOINT <i>name</i> でロールバックする。設定した SAVEPOINT は RELEASE SAVEPOINT <i>name</i> またはトランザクションの終了時に解放される。 BEGIN; INSERT INTO tbl VALUES (1);SAVEPOINT savepoint_example; INSERT INTO tbl VALUES (2);ROLLBACK TO SAVEPOINT savepoint_example; INSERT INTO tbl VALUES (3);COMMIT;-- 1 と 3 が挿入された状態になる。 SAVEPOINT は標準SQLにも採用されており、PostgreSQL, Oracle Database, Microsoft SQL Server(SAVE TRAN[SACTION] nameの書式), MySQL, DB2, SQLite (3.6.8 以降), Firebird, Informix Dynamic Server (11.50xC3 以降) など、多くの関係データベース管理システムがサポートしている。
Abstract from DBpedia / Wikipedia · CC BY-SA