-------------------------------------------------------
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. 默认情况下, MySQL的运行autocommit模式。这意味着,当你执行一项声明中更新(修改)一个表, MySQL的存储磁盘上的更新。
If you are using a transaction-safe storage engine (such as InnoDB, BDB, or NDB Cluster), you can disable autocommit mode with the following statement: 如果您使用的是交易安全的存储引擎(如InnoDB的,边防局,或导航台集群) ,您可以禁用autocommit模式,声明如下:
SET AUTOCOMMIT=0;
After disabling autocommit mode by setting the AUTOCOMMIT variable to zero, you must use COMMIT to store your changes to disk or ROLLBACK if you want to ignore the changes you have made since the beginning of your transaction. 禁用autocommit模式后,通过设置AUTOCOMMIT变量为零,您必须使用致力于存储更改到磁盘或ROLLBACK如果你想改变你忽略了年初以来,您的交易。
To disable autocommit mode for a single series of statements, use the START TRANSACTION statement:
要禁用autocommit模式的一个单一的一系列声明,使用START TRANSACTION语句:
START TRANSACTION;
SELECT @A:=SUM(salary) FROM table1 WHERE type=1;
UPDATE table2 SET summary=@A WHERE type=1;
COMMIT;
With START TRANSACTION, autocommit remains disabled until you end the transaction with COMMIT or ROLLBACK. The autocommit mode then reverts to its previous state. START TRANSACTION, autocommit仍然停用,直到您结束交易凯明或ROLLBACK 。在autocommit模式然后恢复到原来的状态。