zoukankan      html  css  js  c++  java
  • Mysql 关闭自动提交

    回话级关闭自动提交
    mysql> set autocommit=off;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql>  show variables like 'autocommit';
    +---------------+-------+
    | Variable_name | Value |
    +---------------+-------+
    | autocommit    | OFF   |
    +---------------+-------+
    1 row in set (0.00 sec)
    
    
    
    回话1:
    mysql> desc t1
        -> ;
    +-------+---------+------+-----+---------+-------+
    | Field | Type    | Null | Key | Default | Extra |
    +-------+---------+------+-----+---------+-------+
    | id    | int(11) | YES  |     | NULL    |       |
    +-------+---------+------+-----+---------+-------+
    1 row in set (0.00 sec)
    
    mysql> select * from t1;
    +------+
    | id   |
    +------+
    |    1 |
    +------+
    1 row in set (0.00 sec)
    
    mysql> insert into t1 values(2);
    Query OK, 1 row affected (0.01 sec)
    
    mysql> select * from t1;
    +------+
    | id   |
    +------+
    |    1 |
    |    2 |
    +------+
    2 rows in set (0.00 sec)
    
    
    回话2:
    mysql> select * from t1;
    +------+
    | id   |
    +------+
    |    1 |
    +------+
    1 row in set (0.00 sec)
    
    可以看到此时关闭自动提交已经生效
    mysql> select * from t1;
    +------+
    | id   |
    +------+
    |    1 |
    |    2 |
    +------+
    2 rows in set (0.00 sec)
    
    mysql> rollback;
    Query OK, 0 rows affected (0.06 sec)
    
    mysql>  select * from t1;
    +------+
    | id   |
    +------+
    |    1 |
    +------+
    1 row in set (0.00 sec)

  • 相关阅读:
    hashlib 库
    包--json 与 pickle 模块
    模块
    叠加多个装饰器,列表生成式,字典生成式,匿名函数
    函数的递归调用和二分法
    Redis之哨兵模式
    Redis之集群
    Redis之主从复制
    Django之redis-session
    Python操作redis
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13351795.html
Copyright © 2011-2022 走看看