| 1 |
<!-- |
| 2 |
doc/src/sgml/ref/rollback.sgml |
| 3 |
PostgreSQL documentation |
| 4 |
--> |
| 5 |
|
| 6 |
<refentry id="sql-rollback"> |
| 7 |
<indexterm zone="sql-rollback"> |
| 8 |
<primary>ROLLBACK</primary> |
| 9 |
</indexterm> |
| 10 |
|
| 11 |
<refmeta> |
| 12 |
<refentrytitle>ROLLBACK</refentrytitle> |
| 13 |
<manvolnum>7</manvolnum> |
| 14 |
<refmiscinfo>SQL - Language Statements</refmiscinfo> |
| 15 |
</refmeta> |
| 16 |
|
| 17 |
<refnamediv> |
| 18 |
<refname>ROLLBACK</refname> |
| 19 |
<refpurpose>abort the current transaction</refpurpose> |
| 20 |
</refnamediv> |
| 21 |
|
| 22 |
<refsynopsisdiv> |
| 23 |
<synopsis> |
| 24 |
ROLLBACK [ WORK | TRANSACTION ] [ AND [ NO ] CHAIN ] |
| 25 |
</synopsis> |
| 26 |
</refsynopsisdiv> |
| 27 |
|
| 28 |
<refsect1> |
| 29 |
<title>Description</title> |
| 30 |
|
| 31 |
<para> |
| 32 |
<command>ROLLBACK</command> rolls back the current transaction and causes |
| 33 |
all the updates made by the transaction to be discarded. |
| 34 |
</para> |
| 35 |
</refsect1> |
| 36 |
|
| 37 |
<refsect1> |
| 38 |
<title>Parameters</title> |
| 39 |
|
| 40 |
<indexterm zone="sql-rollback-chain"> |
| 41 |
<primary>chained transactions</primary> |
| 42 |
</indexterm> |
| 43 |
|
| 44 |
<variablelist> |
| 45 |
<varlistentry id="sql-rollback-transaction"> |
| 46 |
<term><literal>WORK</literal></term> |
| 47 |
<term><literal>TRANSACTION</literal></term> |
| 48 |
<listitem> |
| 49 |
<para> |
| 50 |
Optional key words. They have no effect. |
| 51 |
</para> |
| 52 |
</listitem> |
| 53 |
</varlistentry> |
| 54 |
|
| 55 |
<varlistentry id="sql-rollback-chain"> |
| 56 |
<term><literal>AND CHAIN</literal></term> |
| 57 |
<listitem> |
| 58 |
<para> |
| 59 |
If <literal>AND CHAIN</literal> is specified, a new (not aborted) |
| 60 |
transaction is immediately started with the same transaction |
| 61 |
characteristics (see <xref linkend="sql-set-transaction"/>) as the |
| 62 |
just finished one. Otherwise, no new transaction is started. |
| 63 |
</para> |
| 64 |
</listitem> |
| 65 |
</varlistentry> |
| 66 |
</variablelist> |
| 67 |
</refsect1> |
| 68 |
|
| 69 |
<refsect1> |
| 70 |
<title>Notes</title> |
| 71 |
|
| 72 |
<para> |
| 73 |
Use <link linkend="sql-commit"><command>COMMIT</command></link> to |
| 74 |
successfully terminate a transaction. |
| 75 |
</para> |
| 76 |
|
| 77 |
<para> |
| 78 |
Issuing <command>ROLLBACK</command> outside of a transaction |
| 79 |
block emits a warning and otherwise has no effect. <command>ROLLBACK AND |
| 80 |
CHAIN</command> outside of a transaction block is an error. |
| 81 |
</para> |
| 82 |
</refsect1> |
| 83 |
|
| 84 |
<refsect1> |
| 85 |
<title>Examples</title> |
| 86 |
|
| 87 |
<para> |
| 88 |
To abort all changes: |
| 89 |
<programlisting> |
| 90 |
ROLLBACK; |
| 91 |
</programlisting></para> |
| 92 |
</refsect1> |
| 93 |
|
| 94 |
<refsect1> |
| 95 |
<title>Compatibility</title> |
| 96 |
|
| 97 |
<para> |
| 98 |
The command <command>ROLLBACK</command> conforms to the SQL standard. The |
| 99 |
form <literal>ROLLBACK TRANSACTION</literal> is a PostgreSQL extension. |
| 100 |
</para> |
| 101 |
</refsect1> |
| 102 |
|
| 103 |
<refsect1> |
| 104 |
<title>See Also</title> |
| 105 |
|
| 106 |
<simplelist type="inline"> |
| 107 |
<member><xref linkend="sql-begin"/></member> |
| 108 |
<member><xref linkend="sql-commit"/></member> |
| 109 |
<member><xref linkend="sql-rollback-to"/></member> |
| 110 |
</simplelist> |
| 111 |
</refsect1> |
| 112 |
</refentry> |