> ## 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/v24.2/sql-statements) commits the current [transaction](https://docs.cockroachlabs.com/docs/v24.2/transactions) or, when using [advanced client-side transaction retries](https://docs.cockroachlabs.com/docs/v24.2/advanced-client-side-transaction-retries), clears the connection to allow new transactions to begin.

When using [advanced client-side transaction retries](https://docs.cockroachlabs.com/docs/v24.2/advanced-client-side-transaction-retries), statements issued after [`SAVEPOINT`](https://docs.cockroachlabs.com/docs/v24.2/savepoint) are committed when [`RELEASE SAVEPOINT`](https://docs.cockroachlabs.com/docs/v24.2/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/v24.2/transactions#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/O8LdfYQ-dz7oGPVh/images/sql-diagrams/v24.2/commit_transaction.svg?fit=max\&auto=format\&n=O8LdfYQ-dz7oGPVh\&q=85\&s=492dc7a92755285f17dc6bff5db93c09)

## Required privileges

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

#### Client-side retryable transactions

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

> [!CAUTION]
>
> This example assumes you're using client-side retry handling.

#### Automatically retried transactions

If you are using transactions that CockroachDB will [automatically retry](https://docs.cockroachlabs.com/docs/v24.2/transactions#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/v24.2/transactions)
* [`BEGIN`](https://docs.cockroachlabs.com/docs/v24.2/begin-transaction)
* [`RELEASE SAVEPOINT`](https://docs.cockroachlabs.com/docs/v24.2/release-savepoint)
* [`ROLLBACK`](https://docs.cockroachlabs.com/docs/v24.2/rollback-transaction)
* [`SAVEPOINT`](https://docs.cockroachlabs.com/docs/v24.2/savepoint)
* [`SHOW SAVEPOINT STATUS`](https://docs.cockroachlabs.com/docs/v24.2/show-savepoint-status)
