zoukankan      html  css  js  c++  java
  • 关于mysql MYISAM引擎的锁问题

    CREATE TABLE `citymy` (

      `city_id` smallint(5) unsigned NOT NULL DEFAULT '0',

      `city` varchar(50) CHARACTER SET utf8 NOT NULL,

      `country_id` smallint(5) unsigned NOT NULL,

      `last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP

    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;

    LOCK TABLES

        tbl_name [[AS] alias] lock_type

        [, tbl_name [[AS] alias] lock_type] ...

     

    lock_type:

        READ [LOCAL]

      | [LOW_PRIORITY] WRITE

     

    UNLOCK TABLES

    LOCK TABLE citymy READ;

    mysql> delete from citymy;

      

    mysql>show processlist;

    +----+------+--------------------+--------+---------+------+------------------------------+--------------------+

    | Id | User | Host               | db     | Command | Time | State                        | Info               |

    +----+------+--------------------+--------+---------+------+------------------------------+--------------------+

    |  3 | root | localhost          | sakila | Query   | 1287 | Waiting for table level lock | delete from citymy |

    |  8 | root | 10.180.2.152:51043 | sakila | Sleep   |  350 |                              | NULL               |

    |  9 | root | 10.180.2.152:51044 | NULL   | Sleep   | 1701 |                              | NULL               |

    | 40 | root | localhost          | NULL   | Query   |    0 | init                         | show processlist   |

    +----+------+--------------------+--------+---------+------+------------------------------+--------------------+

    4 rows in set (0.00 sec)

    mysql> drop table citymy;

    mysql> show processlist;

    +----+------+--------------------+--------+---------+------+---------------------------------+--------------------+

    | Id | User | Host               | db     | Command | Time | State                           | Info               |

    +----+------+--------------------+--------+---------+------+---------------------------------+--------------------+

    |  3 | root | localhost          | sakila | Query   | 1468 | Waiting for table level lock    | delete from citymy |

    |  8 | root | 10.180.2.152:51043 | sakila | Sleep   |  531 |                                 | NULL               |

    |  9 | root | 10.180.2.152:51044 | NULL   | Sleep   | 1882 |                                 | NULL               |

    | 40 | root | localhost          | NULL   | Query   |    0 | init                            | show processlist   |

    | 43 | root | localhost          | sakila | Query   |   94 | Waiting for table metadata lock | drop table citymy  |

    | 44 | root | localhost          | sakila | Query   |   26 | Waiting for table metadata lock | drop table citymy  |

    +----+------+--------------------+--------+---------+------+---------------------------------+--------------------+

    6 rows in set (0.00 sec)

  • 相关阅读:
    JVM之内存区域
    记录Spring Boot小项目的一些坑
    JVM之编译OpenJDK
    Java容器之HashMap源码分析1
    IO流(1)--文件流及其原理
    IO流(0)
    Java中的字节和字符
    整理全网优秀的API接口设计及相关优秀的接口管理、在线文档生成工具
    关于智慧城市的建设方案和资料,相关内容大多来源于互联网,收集整理方便项目经理、产品经理、相关交通领域公司的使用
    整理可视化大屏设计教程与相关资源,大屏设计,可视化
  • 原文地址:https://www.cnblogs.com/karmapeng/p/6019870.html
Copyright © 2011-2022 走看看