Oracle 5.0 Reference Manual page 1131

Table of Contents

Advertisement

START
These statements provide control over use of transactions:
START TRANSACTION
commits the current transaction, making its changes permanent
COMMIT
rolls back the current transaction, canceling its changes
ROLLBACK
disables or enables the default autocommit mode for the current session
SET autocommit
By default, MySQL runs with autocommit mode enabled. This means that as soon as you execute a
statement that updates (modifies) a table, MySQL stores the update on disk to make it permanent.
To disable autocommit mode implicitly for a single series of statements, use the
statement:
START TRANSACTION;
SELECT @A:=SUM(salary) FROM table1 WHERE type=1;
UPDATE table2 SET summary=@A WHERE type=1;
COMMIT;
With
TRANSACTION, autocommit remains disabled until you end the transaction with
START
or ROLLBACK. The autocommit mode then reverts to its previous state.
You can also begin a transaction like this:
START TRANSACTION WITH CONSISTENT SNAPSHOT;
The
WITH CONSISTENT SNAPSHOT
capable of it. This applies only to InnoDB. The effect is the same as issuing a
followed by a
from any
SELECT
The
WITH CONSISTENT SNAPSHOT
it provides a consistent snapshot only if the current isolation level is one that permits consistent read
(REPEATABLE READ
[1120]
Important
Many APIs used for writing MySQL client applications (such as JDBC) provide
their own methods for starting transactions that can (and sometimes should) be
used instead of sending a
Chapter 20, Connectors and
information.
To disable autocommit mode explicitly, use the following statement:
SET autocommit=0;
After disabling autocommit mode by setting the
transaction-safe tables (such as those for InnoDB, BDB, or NDBCLUSTER) are not made permanent
immediately. You must use
[436]
is a session variable and must be set for each session. To disable autocommit
autocommit
mode for each new connection, see the description of the
Section 5.1.4, "Server System
and
BEGIN
BEGIN WORK
START TRANSACTION
transaction.
The
statement differs from the use of the
BEGIN
compound statement. The latter does not begin a transaction. See
Compound-Statement
Syntax".
TRANSACTION, COMMIT, and
or
start a new transaction
BEGIN
option starts a consistent read for storage engines that are
table. See
InnoDB
option does not change the current transaction isolation level, so
or
SERIALIZABLE
START TRANSACTION
to store your changes to disk or
COMMIT
Variables".
are supported as aliases of
is standard SQL syntax and is the recommended way to start an ad-hoc
1111
Syntax
ROLLBACK
Section 14.2.7.2, "Consistent Nonlocking
[1121]).
statement from the client. See
APIs, or the documentation for your API, for more
[436]
variable to zero, changes to
autocommit
ROLLBACK
autocommit
START TRANSACTION
keyword that starts a
BEGIN
Section 13.6.1,
START TRANSACTION
COMMIT
START TRANSACTION
Reads".
to ignore the changes.
[436]
system variable at
for initiating a transaction.
BEGIN ... END
"BEGIN ... END

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents