zoukankan      html  css  js  c++  java
  • innodb和myisam 对事务的处理

    innodb和myisam 对事务的处理:
    
    
    mysql> show create table test200G;
    *************************** 1. row ***************************
           Table: test200
    Create Table: CREATE TABLE `test200` (
      `id` int(11) DEFAULT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8
    1 row in set (0.01 sec)
    
    ERROR: 
    
    对innodb 关闭自动提交:
    
    SESSION A:
    
    mysql>  set autocommit=off;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> select * from test200;
    Empty set (0.00 sec)
    
    mysql> insert into test200 values(200);
    Query OK, 1 row affected (0.00 sec)
    
    mysql> select * from test200;
    +------+
    | id   |
    +------+
    |  200 |
    +------+
    1 row in set (0.00 sec)
    
    
    
    SESSION B:
    
    mysql>  select * from test200;
    Empty set (0.00 sec)
    
    mysql> 
    
    innodb 在关闭自动提交的情况下,事务隔离。
    
    
    
    ----------------------------------------------------------------------------
    mysql> create table test200(id int) ENGINE=MyISAM;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> show create table test200G;
    *************************** 1. row ***************************
           Table: test200
    Create Table: CREATE TABLE `test200` (
      `id` int(11) DEFAULT NULL
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8
    1 row in set (0.00 sec)
    
    ERROR: 
    No query specified
    
    SESSION A:
    mysql>  set autocommit=off;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> insert into test200 values(200);
    Query OK, 1 row affected (0.00 sec)
    
    mysql> select * from test200;
    +------+
    | id   |
    +------+
    |  200 |
    +------+
    1 row in set (0.00 sec)
    
    
    SESSION B:
    mysql> select * from test200;
    +------+
    | id   |
    +------+
    |  200 |
    +------+
    1 row in set (0.00 sec)
    
    mysql> 
    
    myisam 不支持事务,没有事务隔离概念。
    
    
    ---------------------------------------------------------------------------
    
    测试 myisam 更新锁全表:
    
    mysql> select min(sn),max(sn) from Client;
    +---------+---------+
    | min(sn) | max(sn) |
    +---------+---------+
    |       1 |    1772 |
    +---------+---------+
    1 row in set (0.38 sec)
    
    
    
    
    


  • 相关阅读:
    WinForm:实现类似QQ消息框一样的右下角消息提示窗口
    WinForm:系统托盘NotifyIcon
    多线程学习系列:(一)前言
    Codeforces Round #176 (Div. 2)总结A. IQ Test
    使用STL的next_permutation函数生成全排列(C++)
    c语言字符串 数字转换函数大全
    c语言中字符串处理函数
    杭电OJ题目分类
    Codeforces Beta Round #77 (Div. 2 Only)A. Football
    算法导论第三版目录
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13351239.html
Copyright © 2011-2022 走看看