---
title: COMMIT
description: Commit the current interactive transaction and make all of its changes permanent with COMMIT in Databricks SQL.
canonical_url: https://docs.databricks.com/gcp/en/sql/language-manual/sql-ref-syntax-txn-commit
---

# COMMIT

**Applies to:** ![check marked yes](https://docs.databricks.com/gcp/en/images/icons/check.png) Databricks SQL

Commits the current interactive transaction, making all changes across all modified tables permanent. For requirements and usage patterns for interactive transactions, see [Interactive transactions](https://docs.databricks.com/gcp/en/transactions/transaction-modes.md#interactive).

## Syntax

```
COMMIT [ TRANSACTION | WORK ]
```

## Parameters

This statement has no parameters.

## Notes

* If there is no active transaction, executing `COMMIT` results in a [NO\_ACTIVE\_TRANSACTION](https://docs.databricks.com/gcp/en/error-messages/error-classes.md#no_active_transaction) error.
* If `COMMIT` fails, the transaction is aborted and you must explicitly run `ROLLBACK` to reset the transaction state before beginning a new transaction. Common reasons for `COMMIT` failures include write conflicts with other concurrent transactions.
* To execute this statement, you must have an active transaction and appropriate permissions on all the objects read or modified within the transaction.

## Examples

The following examples demonstrate how to commit interactive transactions.

### Basic transaction

Run each statement separately.

```sql
BEGIN TRANSACTION;
```

```sql
-- Insert a new record
INSERT INTO my_table VALUES (1, 'test');
```

```sql
-- Update records in another table
UPDATE another_table
SET value = 'updated'
WHERE id = 5;
```

```sql
-- Commit all changes in both tables atomically
COMMIT TRANSACTION;
```

### Read-your-own-writes

Run each statement separately.

```sql
BEGIN TRANSACTION;
```

```sql
-- Insert new data
INSERT INTO customers VALUES (101, 'New Customer');
```

```sql
-- Update the newly inserted data
UPDATE customers SET name = 'Updated Customer Name' WHERE id = 101;
```

```sql
-- Query sees the updated value within the transaction
SELECT name FROM customers WHERE id = 101;
-- Returns 'Updated Customer Name'
```

```sql
-- Commit makes changes visible to other transactions
COMMIT;
```

### Handle commit failure

If `COMMIT` fails due to conflicts or other errors, you must explicitly roll back. Run each statement separately.

```sql
BEGIN TRANSACTION;
```

```sql
-- Make changes
UPDATE accounts SET balance = balance - 100 WHERE id = 1;
```

```sql
-- Attempt to commit
COMMIT;
-- If COMMIT fails (e.g., due to write conflict),
-- the transaction is aborted
```

```sql
-- You must explicitly roll back before starting a new transaction
ROLLBACK;
```

## <a id="additional-resources" /> Additional resources

* [BEGIN TRANSACTION (interactive transactions)](https://docs.databricks.com/gcp/en/sql/language-manual/sql-ref-syntax-txn-begin.md): Begin an interactive transaction
* [ROLLBACK](https://docs.databricks.com/gcp/en/sql/language-manual/sql-ref-syntax-txn-rollback.md): Roll back an interactive transaction and discard all changes
* [ATOMIC compound statement (non-interactive transactions)](https://docs.databricks.com/gcp/en/sql/language-manual/sql-ref-syntax-txn-begin-atomic.md): Run multiple SQL statements as a single atomic transaction with automatic commit and rollback
* [Transactions](https://docs.databricks.com/gcp/en/transactions/index.md): Overview of transaction support, requirements, and limitations
* [Transaction modes](https://docs.databricks.com/gcp/en/transactions/transaction-modes.md): Detailed patterns and examples for non-interactive and interactive transactions
