Mysql transaction : commit and rollback

前端 未结 2 928
感动是毒
感动是毒 2021-01-01 03:16

I updated my PhpMyAdmin database engine from MyISAM to INNODB to allow rollback.

This is my SQL query :

START TRANSACTION;
UPDATE jkm_content SET st         


        
2条回答
  •  情深已故
    2021-01-01 04:02

    1. Changes you made within one transaction are not visible to other transactions (except transactions with READ UNCOMMITTED isolation level) until the transaction is committed.

    2. There is a huge difference between rolling back transaction and keeping it open forever (or until the engine kill it due to timeout). The latter means server cannot free resources allocated to support transaction. In addition, since you do UPDATE, mysql has to issue exclusive locks on rows affected, and no other transaction can update/delete these rows. If you have an application that leaves transactions open, you will very likely end up with either all connections busy and waiting forever, or bunch of deadlocks .

    3. Yes, they all start a new transaction in mysql.

提交回复
热议问题