savepoint.7

来自「PostgreSQL 8.2中增加了很多企业用户所需要的功能和性能上的提高,其开」· 7 代码 · 共 72 行

7
72
字号
.\\" auto-generated by docbook2man-spec $Revision: 1.1.1.1 $.TH "SAVEPOINT" "" "2008-01-03" "SQL - Language Statements" "SQL Commands".SH NAMESAVEPOINT \- define a new savepoint within the current transaction.SH SYNOPSIS.sp.nfSAVEPOINT \fIsavepoint_name\fR.sp.fi.SH "DESCRIPTION".PP\fBSAVEPOINT\fR establishes a new savepoint withinthe current transaction..PPA savepoint is a special mark inside a transaction that allows all commandsthat are executed after it was established to be rolled back, restoringthe transaction state to what it was at the time of the savepoint..SH "PARAMETERS".TP\fB\fIsavepoint_name\fB\fRThe name to give to the new savepoint..SH "NOTES".PPUse ROLLBACK TO SAVEPOINT [\fBrollback_to_savepoint\fR(7)] torollback to a savepoint. Use RELEASE SAVEPOINT [\fBrelease_savepoint\fR(7)] to destroy a savepoint, keepingthe effects of commands executed after it was established..PPSavepoints can only be established when inside a transaction block.There can be multiple savepoints defined within a transaction..SH "EXAMPLES".PPTo establish a savepoint and later undo the effects of all commands executedafter it was established:.sp.nfBEGIN;    INSERT INTO table1 VALUES (1);    SAVEPOINT my_savepoint;    INSERT INTO table1 VALUES (2);    ROLLBACK TO SAVEPOINT my_savepoint;    INSERT INTO table1 VALUES (3);COMMIT;.sp.fiThe above transaction will insert the values 1 and 3, but not 2..PPTo establish and later destroy a savepoint:.sp.nfBEGIN;    INSERT INTO table1 VALUES (3);    SAVEPOINT my_savepoint;    INSERT INTO table1 VALUES (4);    RELEASE SAVEPOINT my_savepoint;COMMIT;.sp.fiThe above transaction will insert both 3 and 4..SH "COMPATIBILITY".PPSQL requires a savepoint to be destroyed automatically when anothersavepoint with the same name is established. InPostgreSQL, the old savepoint is kept, though only the morerecent one will be used when rolling back or releasing. (Releasing thenewer savepoint will cause the older one to again become accessible to\fBROLLBACK TO SAVEPOINT\fR and \fBRELEASE SAVEPOINT\fR.)Otherwise, \fBSAVEPOINT\fR is fully SQL conforming..SH "SEE ALSO"BEGIN [\fBbegin\fR(7)], COMMIT [\fBcommit\fR(l)], RELEASE SAVEPOINT [\fBrelease_savepoint\fR(l)], ROLLBACK [\fBrollback\fR(l)], ROLLBACK TO SAVEPOINT [\fBrollback_to_savepoint\fR(l)]

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?