• 关于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)

  • 相关阅读:
    Redundant Paths 分离的路径(边双连通分量)
    bzoj2208 [Jsoi2010] 连通数(tarjan点双连通分量 // dfs)
    [bzoj3331] [BeiJing2013] 压力(tarjan 点双连通分量)
    [ BZOJ1123 ] BLO(tarjan点双连通分量)
    bitset小总结
    牛客328B Rabbit的工作(1)
    # Codeforces Round #529(Div.3)个人题解
    HDU5957 Query on a graph(拓扑找环,BFS序,线段树更新,分类讨论)
    istringstream()函数的用法
    codeforces 1077F1
  • 原文地址:https://www.cnblogs.com/karmapeng/p/6019870.html
Copyright © 2020-2023  润新知