// Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements.  See the NOTICE file distributed with
// this work for additional information regarding copyright ownership.
// The ASF licenses this file to You under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with
// the License.  You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
= Transactions

IMPORTANT: Support for link:transactions/mvcc[SQL transactions] is currently in the beta stage. For production use, consider key-value transactions.

Ignite supports the following statements that allow users to start, commit, or rollback a transaction.

[source,sql]
----
BEGIN [TRANSACTION]

COMMIT [TRANSACTION]

ROLLBACK [TRANSACTION]
----

- The `BEGIN` statement begins a new transaction.
- `COMMIT` commits the current transaction.
- `ROLLBACK` rolls back the current transaction.

NOTE: DDL statements are not supported inside transactions.

== Description

The `BEGIN`, `COMMIT` and `ROLLBACK` commands allow you to manage SQL Transactions. A transaction is a sequence of SQL operations that starts with the `BEGIN` statement and ends with the `COMMIT` statement. Either all of the operations in a transaction succeed or they all fail.

The `ROLLBACK [TRANSACTION]` statement undoes all updates made since the last time a `COMMIT` or `ROLLBACK` command was issued.

== Example
Add a person and update the city population by 1 in a single transaction.

[source,sql]
----
BEGIN;

INSERT INTO Person (id, name, city_id) VALUES (1, 'John Doe', 3);

UPDATE City SET population = population + 1 WHERE id = 3;

COMMIT;
----

Roll back the changes made by the previous commands.

[source,sql]
----
BEGIN;

INSERT INTO Person (id, name, city_id) VALUES (1, 'John Doe', 3);

UPDATE City SET population = population + 1 WHERE id = 3;
----

