Difference between SET autocommit=1 and START TRANSACTION in mysql (Have I missed something?)

前端 未结 4 1946
清酒与你
清酒与你 2020-11-28 02:10

I am reading up on transactions in MySQL and am not sure whether I have grasped something specific correctly, and I want to be sure I understood that correctly, so here goes

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-28 02:47

    If you want to use rollback, then use start transaction and otherwise forget all those things,

    By default, MySQL automatically commits the changes to the database.

    To force MySQL not to commit these changes automatically, execute following:

    SET autocommit = 0;
    //OR    
    SET autocommit = OFF
    

    To enable the autocommit mode explicitly:

    SET autocommit = 1;
    //OR    
    SET autocommit = ON;
    

提交回复
热议问题