> ## Documentation Index
> Fetch the complete documentation index at: https://cockroachlabs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# COMMIT

export const InternalLink = ({version, path = "", children, ...props}) => {
  let detectedVersion = version || "stable";
  if (typeof window !== 'undefined' && !version) {
    const match = window.location.pathname.match(/\/docs\/([^/]+)/);
    if (match) {
      detectedVersion = match[1];
    }
  }
  const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
  return <a href={`/docs/${detectedVersion}/${normalizedPath}`} {...props}>
      {children}
    </a>;
};

The `COMMIT` <InternalLink path="sql-statements">statement</InternalLink> commits the current <InternalLink path="transactions">transaction</InternalLink> or, when using <InternalLink path="advanced-client-side-transaction-retries">advanced client-side transaction retries</InternalLink>, clears the connection to allow new transactions to begin.

When using <InternalLink path="advanced-client-side-transaction-retries">advanced client-side transaction retries</InternalLink>, statements issued after <InternalLink path="savepoint">`SAVEPOINT`</InternalLink> are committed when <InternalLink path="release-savepoint">`RELEASE SAVEPOINT`</InternalLink> is issued instead of `COMMIT`. However, you must still issue a `COMMIT` statement to clear the connection for the next transaction.

For non-retryable transactions, if statements in the transaction <InternalLink path="transactions#error-handling">generated any errors</InternalLink>, `COMMIT` is equivalent to `ROLLBACK`, which aborts the transaction and discards *all* updates made by its statements.

## Synopsis

<img src="https://mintcdn.com/cockroachlabs/uBcLAizjWFXF4pfd/images/sql-diagrams/v25.1/commit_transaction.svg?fit=max&auto=format&n=uBcLAizjWFXF4pfd&q=85&s=8565afd34d36145b9f55ffd773d56f75" alt="commit_transaction syntax diagram" style={{maxWidth: "100%", overflowX: "auto"}} width="317" height="69" data-path="images/sql-diagrams/v25.1/commit_transaction.svg" />

## Required privileges

No <InternalLink path="security-reference/authorization#managing-privileges">privileges</InternalLink> are required to commit a transaction. However, privileges are required for each statement within a transaction.

## Aliases

In CockroachDB, `END` is an alias for the `COMMIT` statement.

## Example

### Commit a transaction

How you commit transactions depends on how your application handles <InternalLink path="transactions#transaction-retries">transaction retries</InternalLink>.

#### Client-side retryable transactions

When using <InternalLink path="advanced-client-side-transaction-retries">advanced client-side transaction retries</InternalLink>, statements are committed by <InternalLink path="release-savepoint">`RELEASE SAVEPOINT`</InternalLink>. `COMMIT` itself only clears the connection for the next transaction.

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> BEGIN;
```

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> SAVEPOINT cockroach_restart;
```

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> UPDATE products SET inventory = 0 WHERE sku = '8675309';
```

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> INSERT INTO orders (customer, sku, status) VALUES (1001, '8675309', 'new');
```

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> RELEASE SAVEPOINT cockroach_restart;
```

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> COMMIT;
```

<Danger>
  This example assumes you're using client-side retry handling.
</Danger>

#### Automatically retried transactions

If you are using transactions that CockroachDB will <InternalLink path="transactions#automatic-retries">automatically retry</InternalLink> (i.e., all statements sent in a single batch), commit the transaction with `COMMIT`.

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> BEGIN; UPDATE products SET inventory = 100 WHERE = '8675309'; UPDATE products SET inventory = 100 WHERE = '8675310'; COMMIT;
```

## See also

* <InternalLink path="transactions">Transactions</InternalLink>
* <InternalLink path="begin-transaction">`BEGIN`</InternalLink>
* <InternalLink path="release-savepoint">`RELEASE SAVEPOINT`</InternalLink>
* <InternalLink path="rollback-transaction">`ROLLBACK`</InternalLink>
* <InternalLink path="savepoint">`SAVEPOINT`</InternalLink>
* <InternalLink path="show-savepoint-status">`SHOW SAVEPOINT STATUS`</InternalLink>
