📄 rollback_to_savepoint.7
字号:
.\\" auto-generated by docbook2man-spec $Revision: 1.1.1.1 $.TH "ROLLBACK TO SAVEPOINT" "" "2008-01-03" "SQL - Language Statements" "SQL Commands".SH NAMEROLLBACK TO SAVEPOINT \- roll back to a savepoint.SH SYNOPSIS.sp.nfROLLBACK [ WORK | TRANSACTION ] TO [ SAVEPOINT ] \fIsavepoint_name\fR.sp.fi.SH "DESCRIPTION".PPRoll back all commands that were executed after the savepoint wasestablished. The savepoint remains valid and can be rolled back toagain later, if needed..PP\fBROLLBACK TO SAVEPOINT\fR implicitly destroys all savepoints thatwere established after the named savepoint..SH "PARAMETERS".TP\fB\fIsavepoint_name\fB\fRThe savepoint to roll back to..SH "NOTES".PPUse RELEASE SAVEPOINT [\fBrelease_savepoint\fR(7)] to destroy a savepoint withoutdiscarding the effects of commands executed after it was established..PPSpecifying a savepoint name that has not been established is an error..PPCursors have somewhat non-transactional behavior with respect tosavepoints. Any cursor that is opened inside a savepoint will be closedwhen the savepoint is rolled back. If a previously opened cursor isaffected by a \fBFETCH\fR command inside a savepoint that is later rolledback, the cursor position remains at the position that \fBFETCH\fRleft it pointing to (that is, \fBFETCH\fR is not rolled back).Closing a cursor is not undone by rolling back, either.A cursor whose execution causes a transaction to abort is put in acan't-execute state, so while the transaction can be restored using\fBROLLBACK TO SAVEPOINT\fR, the cursor can no longer be used..SH "EXAMPLES".PPTo undo the effects of the commands executed after my_savepointwas established:.sp.nfROLLBACK TO SAVEPOINT my_savepoint;.sp.fi.PPCursor positions are not affected by savepoint rollback:.sp.nfBEGIN;DECLARE foo CURSOR FOR SELECT 1 UNION SELECT 2;SAVEPOINT foo;FETCH 1 FROM foo; ?column? ---------- 1ROLLBACK TO SAVEPOINT foo;FETCH 1 FROM foo; ?column? ---------- 2COMMIT;.sp.fi.SH "COMPATIBILITY".PPThe SQL standard specifies that the key wordSAVEPOINT is mandatory, but PostgreSQLand Oracle allow it to be omitted. SQL allowsonly WORK, not TRANSACTION, as a noise wordafter ROLLBACK. Also, SQL has an optional clauseAND [ NO ] CHAIN which is not currently supported byPostgreSQL. Otherwise, this command conforms tothe SQL standard..SH "SEE ALSO"BEGIN [\fBbegin\fR(7)], COMMIT [\fBcommit\fR(l)], RELEASE SAVEPOINT [\fBrelease_savepoint\fR(l)], ROLLBACK [\fBrollback\fR(l)], SAVEPOINT [\fBsavepoint\fR(l)]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -