mysql autocommit

1、autocommit是mysql中的InnoDb数据表特有的语句。(只有在表引擎=InnoDb时,autocommit才会生效)

原理:在InnoDb表中,所有的语句都是需要commit后,才会在真实数据库中生效。

eg:

InnoDb数据库引擎 :

    update tablenam set id = 999 where id = 1;(缓存生效)

    commit;(真实生效)

其它数据库引擎 :

    update tablenam set id = 999 where id = 1;(真实生效)

2、用在哪里?

    用于InnoDb表。

    在没有开启事务(begin;)的InnoDB表中,autocommit 才生效。

    对已经开启了事务的SQL语句,autocommit 参数不生效。

3、怎么用?

    a)查看:select @@autocmmit;

    b)修改:set autocommit = 0;(默认是1)

4. 3中的设置只对当前connection有效
posted @ 2018-03-04 10:01  車輪の唄  阅读(64)  评论(0)    收藏  举报  来源