Skip to content

Latest commit

 

History

History
50 lines (35 loc) · 1.63 KB

File metadata and controls

50 lines (35 loc) · 1.63 KB
title ROLLBACK | TiDB SQL Statement Reference
summary An overview of the usage of ROLLBACK for the TiDB database.

ROLLBACK

This statement reverts all changes in the current transaction inside of TiDB. It is the opposite of a COMMIT statement.

Synopsis

RollbackStmt ::=
    'ROLLBACK' CompletionTypeWithinTransaction?

CompletionTypeWithinTransaction ::=
    'AND' ( 'CHAIN' ( 'NO' 'RELEASE' )? | 'NO' 'CHAIN' ( 'NO'? 'RELEASE' )? )
|   'NO'? 'RELEASE'

Examples

mysql> CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY);
Query OK, 0 rows affected (0.12 sec)

mysql> BEGIN;
Query OK, 0 rows affected (0.00 sec)

mysql> INSERT INTO t1 VALUES (1);
Query OK, 1 row affected (0.00 sec)

mysql> ROLLBACK;
Query OK, 0 rows affected (0.01 sec)

mysql> SELECT * FROM t1;
Empty set (0.01 sec)

MySQL compatibility

  • TiDB parses but ignores the syntax ROLLBACK AND [NO] RELEASE. This functionality is used in MySQL to disconnect the client session immediately after rolling back the transaction. In TiDB, it is recommended to instead use the mysql_close() functionality of your client driver.
  • TiDB parses but ignores the syntax ROLLBACK AND [NO] CHAIN. This functionality is used in MySQL to immediately start a new transaction with the same isolation level while the current transaction is being rolled back. In TiDB, it is recommended to instead start a new transaction.

See also