Skip to content

Latest commit

 

History

History
44 lines (29 loc) · 1.34 KB

sql-statement-rollback.md

File metadata and controls

44 lines (29 loc) · 1.34 KB
title summary aliases
ROLLBACK | TiDB SQL Statement Reference
An overview of the usage of ROLLBACK for the TiDB database.
/docs/dev/sql-statements/sql-statement-rollback/
/docs/dev/reference/sql/statements/rollback/

ROLLBACK

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

Synopsis

RollbackStmt:

RollbackStmt

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

This statement is partly compatible with MySQL. TiDB only has syntactic support for CompletionTypeWithinTransaction. Closing the connection or continuing to open a new transaction after the transaction is rolled back is not supported. Any compatibility differences should be reported via an issue on GitHub.

See also