Name
ROLLBACK
Synopsis
ROLLBACK [WORK] [AND [NO] CHAIN] [[NO] RELEASE]
Use this statement with transactional tables to reverse transactions that have not yet been committed. Transaction statements are currently supported by the InnoDB, NDB Cluster, and BDB storage engines and are ignored if used with MyISAM tables.
If AUTOCOMMIT is enabled, it must be disabled for this statement to be
meaningful, which can be done as follows:
SET AUTOCOMMIT = 0;
AUTOCOMMIT is also disabled when a
transaction is started with the START TRANSACTION
statement. It is reinstated with the execution of the
COMMIT statement, the ending of the current
session, and several other statements that imply that a commit is
desired. See the explanation of COMMIT earlier in
this chapter for a list of statements that imply a commit.
The WORK keyword is optional and has no effect on the results. It’s
available for compatibility with its counterparts, BEGIN
WORK and COMMIT WORK. Use the
AND CHAIN clause to indicate that the transaction is to be rolled back
and another is starting, thus making it unnecessary to execute the
START TRANSACTION statement again. Use the AND RELEASE clause to end the
current client session after rolling back the transaction. Add the
keyword NO to indicate explicitly that a new
transaction is not to begin (when used with CHAIN)
or the client session is not to end (when used with
RELEASE)—these are the default settings, though.
It’s necessary to specify NO only when the system
variable completion_type ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access