2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【MySQL】autocommit

Last updated at Posted at 2016-02-02

autocommitとは

**InnoDBではデフォルトでautocommitは有効。**この状態でトランザクションを実行せずにSQLを実行すると、1つのSQLごとにcommitが行われる。もちろんrollbackは行われない。
トランザクションを実行すれば、明示的にcommitしたタイミングでcommitは行われる。rollbackも可能。

無効にした場合、SQLの実行及びトランザクションの開始でトランザクションが開始する。トランザクションが開始するので、明示的なcommitでcommitされる。

autocommitの変更方法

5.5.8移行であれば、my.cnfに書くことで変更可能。

[mysqld]
autocommit = 1

疑問点

autocommitを無効にするシチュエーションがいまいちよくわからない。
OracleはMySQLと逆でautocommitがデフォルトでOFFらしいので、OracleからMySQLへDBを移行した場合なのかなと。詳しい人いたら教えてください。

参考
MySQLのAUTOCOMMIT(オートコミット)覚え書き
MySQLのautocommitとトランザクション分離レベルのメモ

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?