1999-07-22 11:09:15 -04:00
|
|
|
<!--
|
2010-09-20 16:08:53 -04:00
|
|
|
doc/src/sgml/ref/commit.sgml
|
2001-12-07 22:24:40 -05:00
|
|
|
PostgreSQL documentation
|
1999-07-22 11:09:15 -04:00
|
|
|
-->
|
|
|
|
|
|
2017-10-19 21:16:39 -04:00
|
|
|
<refentry id="sql-commit">
|
2014-02-23 21:25:35 -05:00
|
|
|
<indexterm zone="sql-commit">
|
|
|
|
|
<primary>COMMIT</primary>
|
|
|
|
|
</indexterm>
|
|
|
|
|
|
1999-06-14 03:37:05 -04:00
|
|
|
<refmeta>
|
2010-04-03 03:23:02 -04:00
|
|
|
<refentrytitle>COMMIT</refentrytitle>
|
2008-11-14 05:22:48 -05:00
|
|
|
<manvolnum>7</manvolnum>
|
1999-06-14 03:37:05 -04:00
|
|
|
<refmiscinfo>SQL - Language Statements</refmiscinfo>
|
|
|
|
|
</refmeta>
|
2003-04-15 09:25:08 -04:00
|
|
|
|
1999-06-14 03:37:05 -04:00
|
|
|
<refnamediv>
|
2003-04-15 09:25:08 -04:00
|
|
|
<refname>COMMIT</refname>
|
|
|
|
|
<refpurpose>commit the current transaction</refpurpose>
|
2003-09-11 20:12:47 -04:00
|
|
|
</refnamediv>
|
|
|
|
|
|
1999-06-14 03:37:05 -04:00
|
|
|
<refsynopsisdiv>
|
2003-04-15 09:25:08 -04:00
|
|
|
<synopsis>
|
2019-03-24 05:33:14 -04:00
|
|
|
COMMIT [ WORK | TRANSACTION ] [ AND [ NO ] CHAIN ]
|
2003-04-15 09:25:08 -04:00
|
|
|
</synopsis>
|
1999-06-14 03:37:05 -04:00
|
|
|
</refsynopsisdiv>
|
2010-11-23 15:27:50 -05:00
|
|
|
|
2003-04-15 09:25:08 -04:00
|
|
|
<refsect1>
|
|
|
|
|
<title>Description</title>
|
|
|
|
|
|
1999-06-14 03:37:05 -04:00
|
|
|
<para>
|
1998-09-16 10:43:12 -04:00
|
|
|
<command>COMMIT</command> commits the current transaction. All
|
1998-05-13 01:34:00 -04:00
|
|
|
changes made by the transaction become visible to others
|
|
|
|
|
and are guaranteed to be durable if a crash occurs.
|
1999-06-14 03:37:05 -04:00
|
|
|
</para>
|
2003-04-15 09:25:08 -04:00
|
|
|
</refsect1>
|
2010-11-23 15:27:50 -05:00
|
|
|
|
2003-04-15 09:25:08 -04:00
|
|
|
<refsect1>
|
|
|
|
|
<title>Parameters</title>
|
1999-06-14 03:37:05 -04:00
|
|
|
|
2019-03-24 05:33:14 -04:00
|
|
|
<indexterm zone="sql-commit-chain">
|
|
|
|
|
<primary>chained transactions</primary>
|
|
|
|
|
</indexterm>
|
|
|
|
|
|
2003-04-15 09:25:08 -04:00
|
|
|
<variablelist>
|
2023-01-09 15:08:24 -05:00
|
|
|
<varlistentry id="sql-commit-transaction">
|
2003-04-15 09:25:08 -04:00
|
|
|
<term><literal>WORK</literal></term>
|
|
|
|
|
<term><literal>TRANSACTION</literal></term>
|
|
|
|
|
<listitem>
|
|
|
|
|
<para>
|
|
|
|
|
Optional key words. They have no effect.
|
|
|
|
|
</para>
|
|
|
|
|
</listitem>
|
|
|
|
|
</varlistentry>
|
2019-03-24 05:33:14 -04:00
|
|
|
|
|
|
|
|
<varlistentry id="sql-commit-chain">
|
|
|
|
|
<term><literal>AND CHAIN</literal></term>
|
|
|
|
|
<listitem>
|
|
|
|
|
<para>
|
|
|
|
|
If <literal>AND CHAIN</literal> is specified, a new transaction is
|
|
|
|
|
immediately started with the same transaction characteristics (see <xref
|
|
|
|
|
linkend="sql-set-transaction"/>) as the just finished one. Otherwise,
|
|
|
|
|
no new transaction is started.
|
|
|
|
|
</para>
|
|
|
|
|
</listitem>
|
|
|
|
|
</varlistentry>
|
2003-04-15 09:25:08 -04:00
|
|
|
</variablelist>
|
1998-05-13 01:34:00 -04:00
|
|
|
</refsect1>
|
2003-04-15 09:25:08 -04:00
|
|
|
|
|
|
|
|
<refsect1>
|
|
|
|
|
<title>Notes</title>
|
1998-05-13 01:34:00 -04:00
|
|
|
|
1999-06-14 03:37:05 -04:00
|
|
|
<para>
|
2017-11-23 09:39:47 -05:00
|
|
|
Use <xref linkend="sql-rollback"/> to
|
2003-04-15 09:25:08 -04:00
|
|
|
abort a transaction.
|
|
|
|
|
</para>
|
2003-09-09 14:28:53 -04:00
|
|
|
|
|
|
|
|
<para>
|
2017-10-08 21:44:17 -04:00
|
|
|
Issuing <command>COMMIT</command> when not inside a transaction does
|
2019-09-08 10:11:21 -04:00
|
|
|
no harm, but it will provoke a warning message. <command>COMMIT AND
|
|
|
|
|
CHAIN</command> when not inside a transaction is an error.
|
2003-09-09 14:28:53 -04:00
|
|
|
</para>
|
2003-04-15 09:25:08 -04:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
|
|
<refsect1>
|
|
|
|
|
<title>Examples</title>
|
|
|
|
|
|
|
|
|
|
<para>
|
|
|
|
|
To commit the current transaction and make all changes permanent:
|
|
|
|
|
<programlisting>
|
|
|
|
|
COMMIT;
|
2011-08-07 03:49:45 -04:00
|
|
|
</programlisting></para>
|
1999-06-14 03:37:05 -04:00
|
|
|
</refsect1>
|
2003-09-11 20:12:47 -04:00
|
|
|
|
2003-04-15 09:25:08 -04:00
|
|
|
<refsect1>
|
|
|
|
|
<title>Compatibility</title>
|
2010-11-23 15:27:50 -05:00
|
|
|
|
2003-04-15 09:25:08 -04:00
|
|
|
<para>
|
2019-03-24 05:33:14 -04:00
|
|
|
The command <command>COMMIT</command> conforms to the SQL standard. The
|
|
|
|
|
form <literal>COMMIT TRANSACTION</literal> is a PostgreSQL extension.
|
2003-04-15 09:25:08 -04:00
|
|
|
</para>
|
1998-05-13 01:34:00 -04:00
|
|
|
</refsect1>
|
2003-09-09 14:28:53 -04:00
|
|
|
|
|
|
|
|
<refsect1>
|
|
|
|
|
<title>See Also</title>
|
|
|
|
|
|
|
|
|
|
<simplelist type="inline">
|
2017-11-23 09:39:47 -05:00
|
|
|
<member><xref linkend="sql-begin"/></member>
|
|
|
|
|
<member><xref linkend="sql-rollback"/></member>
|
2003-09-09 14:28:53 -04:00
|
|
|
</simplelist>
|
|
|
|
|
</refsect1>
|
1999-06-14 03:37:05 -04:00
|
|
|
</refentry>
|