Sign InTry Free

COMMIT

This statement commits a transaction inside of the TIDB server.

In the absence of a BEGIN or START TRANSACTION statement, the default behavior of TiDB is that every statement will be its own transaction and autocommit. This behavior ensures MySQL compatibility.

Synopsis

CommitStmt:

CommitStmt

Examples

mysql> CREATE TABLE t1 (a int NOT NULL PRIMARY KEY); Query OK, 0 rows affected (0.12 sec) mysql> START TRANSACTION; Query OK, 0 rows affected (0.00 sec) mysql> INSERT INTO t1 VALUES (1); Query OK, 1 row affected (0.00 sec) mysql> COMMIT; Query OK, 0 rows affected (0.01 sec)

MySQL compatibility

  • By default, TiDB 3.0.8 and later versions use Pessimistic Locking. When using Optimistic Locking, it is important to consider that a COMMIT statement might fail because rows have been modified by another transaction.
  • When Optimistic Locking is enabled, UNIQUE and PRIMARY KEY constraint checks are deferred until statement commit. This results in additional situations where a COMMIT statement might fail. This behavior can be changed by setting tidb_constraint_check_in_place=TRUE.

See also

Download PDF
Playground
New
One-stop & interactive experience of TiDB's capabilities WITHOUT registration.
Products
TiDB
TiDB Dedicated
TiDB Serverless
Pricing
Get Demo
Get Started
© 2024 PingCAP. All Rights Reserved.
Privacy Policy.