Debian Codegraph @

doc/src/sgml/ref/commit.sgml

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