H2 Database - Commit

H2 Database - Commit

COMMIT is a SQL grammar command used to commit a transaction. We can either commit a specific transaction or we can commit the current transaction.

Syntax

There are two different syntaxes for the COMMIT command.

The following is the general syntax for the commit command to commit the current transaction.

COMMIT[WORK] 

Following is the general syntax of the commit command to commit a specific transaction.

COMMIT TRANSACTION

Example 1

In this example, let's commit the current transaction using the following command.

COMMIT

The above command produces the following output.

Committed successfully

Example 2

In this example, we will commit a transaction named tx_test with the following command.

COMMIT TRANSACTION tx_test;

The above command produces the following output.