MySQL: Transactions vs Locking Tables

后端 未结 6 950
孤城傲影
孤城傲影 2020-11-28 00:36

I\'m a bit confused with transactions vs locking tables to ensure database integrity and make sure a SELECT and UPDATE remain in sync and no other connection interferes with

6条回答
  •  遥遥无期
    2020-11-28 01:38

    I'd use a

    START TRANSACTION WITH CONSISTENT SNAPSHOT;
    

    to begin with, and a

    COMMIT;
    

    to end with.

    Anything you do in between is isolated from the others users of your database if your storage engine supports transactions (which is InnoDB).

提交回复
热议问题