COMMIT PREPARED

|    COMMIT PREPARED    |                       |            |                  |                      |
|:---------------------:|-----------------------|------------|------------------|----------------------|
|[Prev](sql-commit.html)|[Up](sql-commands.html)|SQL Commands|[Home](index.html)| [Next](sql-copy.html)|

---

[]()

## COMMIT PREPARED

COMMIT PREPARED — commit a transaction that was earlier prepared for two-phase commit

## Synopsis

```
COMMIT PREPARED transaction_id

```

## Description

`COMMIT PREPARED` commits a transaction that is in prepared state.

## Parameters

*`transaction_id`*

 The transaction identifier of the transaction that is to be committed.

## Notes

 To commit a prepared transaction, you must be either the same user that executed the transaction originally, or a superuser. But you do not have to be in the same session that executed the transaction.

 This command cannot be executed inside a transaction block. The prepared transaction is committed immediately.

 All currently available prepared transactions are listed in the [`pg_prepared_xacts`](view-pg-prepared-xacts.html) system view.

## Examples

 Commit the transaction identified by the transaction identifier `foobar`:

```
COMMIT PREPARED 'foobar';

```

## Compatibility

`COMMIT PREPARED` is a PostgreSQL extension. It is intended for use by external transaction management systems, some of which are covered by standards (such as X/Open XA), but the SQL side of those systems is not standardized.

## See Also

[PREPARE TRANSACTION](sql-prepare-transaction.html), [ROLLBACK PREPARED](sql-rollback-prepared.html)

---

|[Prev](sql-commit.html)|[Up](sql-commands.html)| [Next](sql-copy.html)|
|:----------------------|:---------------------:|---------------------:|
|        COMMIT         |  [Home](index.html)   |         COPY         |

 // \<![CDATA[ \<-- For SVG support if ('WebSocket' in window) { (function() { function refreshCSS() { var sheets = [].slice.call(document.getElementsByTagName("link")); var head = document.getElementsByTagName("head")[0]; for (var i = 0; i \< sheets.length; ++i) { var elem = sheets[i]; head.removeChild(elem); var rel = elem.rel; if (elem.href && typeof rel != "string" || rel.length == 0 || rel.toLowerCase() == "stylesheet") { var url = elem.href.replace(/(&|\\?)\_cacheOverride=\\d+/, ''); elem.href = url + (url.indexOf('?') \>= 0 ? '&' : '?') + '\_cacheOverride=' + (new Date().valueOf()); } head.appendChild(elem); } } var protocol = window.location.protocol === 'http:' ? 'ws://' : 'wss://'; var address = protocol + window.location.host + window.location.pathname + '/ws'; var socket = new WebSocket(address); socket.onmessage = function(msg) { if (msg.data == 'reload') window.location.reload(); else if (msg.data == 'refreshcss') refreshCSS(); }; console.log('Live reload enabled.'); })(); } // ]]\>