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

# COMMIT

The `COMMIT` [statement](https://docs.cockroachlabs.com/docs/v26.4/sql-statements.md) commits the current [transaction](https://docs.cockroachlabs.com/docs/v26.4/transactions.md) or, when using [advanced client-side transaction retries](https://docs.cockroachlabs.com/docs/v26.4/advanced-client-side-transaction-retries.md), clears the connection to allow new transactions to begin.

When using [advanced client-side transaction retries](https://docs.cockroachlabs.com/docs/v26.4/advanced-client-side-transaction-retries.md), statements issued after [`SAVEPOINT`](https://docs.cockroachlabs.com/docs/v26.4/savepoint) are committed when [`RELEASE SAVEPOINT`](https://docs.cockroachlabs.com/docs/v26.4/release-savepoint) 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 [generated any errors](https://docs.cockroachlabs.com/docs/v26.4/transactions.md#error-handling), `COMMIT` is equivalent to `ROLLBACK`, which aborts the transaction and discards *all* updates made by its statements.

## Synopsis

![commit\_transaction syntax diagram](https://mintcdn.com/cockroachlabs/R40d76ku6ZWAJ59v/images/sql-diagrams/v26.4/commit_transaction.svg?fit=max\&auto=format\&n=R40d76ku6ZWAJ59v\&q=85\&s=760653b8fcd06af18d0e6afdf5df32e3)

## Required privileges

No [privileges](https://docs.cockroachlabs.com/docs/v26.4/security-reference/authorization.md#managing-privileges) 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 [transaction retries](https://docs.cockroachlabs.com/docs/v26.4/transactions.md#transaction-retries).

#### Client-side retryable transactions

When using [advanced client-side transaction retries](https://docs.cockroachlabs.com/docs/v26.4/advanced-client-side-transaction-retries.md), statements are committed by [`RELEASE SAVEPOINT`](https://docs.cockroachlabs.com/docs/v26.4/release-savepoint). `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;
```

#### Automatically retried transactions

If you are using transactions that CockroachDB will [automatically retry](https://docs.cockroachlabs.com/docs/v26.4/transactions.md#automatic-retries) (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

* [Transactions](https://docs.cockroachlabs.com/docs/v26.4/transactions.md)
* [`BEGIN`](https://docs.cockroachlabs.com/docs/v26.4/begin-transaction)
* [`RELEASE SAVEPOINT`](https://docs.cockroachlabs.com/docs/v26.4/release-savepoint)
* [`ROLLBACK`](https://docs.cockroachlabs.com/docs/v26.4/rollback-transaction)
* [`SAVEPOINT`](https://docs.cockroachlabs.com/docs/v26.4/savepoint)
* [`SHOW SAVEPOINT STATUS`](https://docs.cockroachlabs.com/docs/v26.4/show-savepoint-status)
