zoukankan      html  css  js  c++  java
  • mysql 表级锁

    表级锁:分为读锁和写锁:
    
    lock   tables   table_name   read;//其他事务只能读,不能加写锁,要等待更新。
     
    SESSION 50 执行:
    mysql> update test set name='ccc' where id=1;
    		 
    		 
    mysql> show full processlist;
    +----+---------+----------------------+--------+---------+------+------------------------------+---------------------------------------+
    | Id | User    | Host                 | db     | Command | Time | State                        | Info                                  |
    +----+---------+----------------------+--------+---------+------+------------------------------+---------------------------------------+
    | 20 | monitor | 115.236.160.82:56186 | NULL   | Sleep   |  162 |                              | NULL                                  |
    | 21 | monitor | 115.236.160.82:56187 | NULL   | Sleep   |  162 |                              | NULL                                  |
    | 23 | monitor | 115.236.160.82:56208 | NULL   | Sleep   |   43 |                              | NULL                                  |
    | 24 | monitor | 115.236.160.82:56209 | NULL   | Sleep   |   43 |                              | NULL                                  |
    | 47 | monitor | 115.236.160.82:54858 | NULL   | Sleep   |   66 |                              | NULL                                  |
    | 48 | monitor | 115.236.160.82:54859 | NULL   | Sleep   |   67 |                              | NULL                                  |
    | 49 | root    | localhost            | DEVOPS | Query   |    0 | init                         | show full processlist                 |
    | 50 | root    | localhost            | DEVOPS | Query   |   27 | Waiting for table level lock | update test set name='ccc' where id=1 |
    +----+---------+----------------------+--------+---------+------+------------------------------+---------------------------------------+
    8 rows in set (0.00 sec)
    
    lock   tables   table_name write;//其他事务不能读
    
    解锁:
    
    unlock  tables;
    
    ---------------------------------------------
    
    行级锁:行锁是对索引加锁
    
    
    
    目前对于表级锁查找持有的thread id 没有好的办法
    

  • 相关阅读:
    struts2 标签 前台遍历 字符串数组 String[]
    007-服务器域名&上传网站
    006-DOS命令
    005-OSI七层模型&IP地址
    004-编程语言发展史
    003-计量单位
    002-B/S架构&C/S架构
    001-计算机的组成
    1083. List Grades (25)
    1037. Magic Coupon (25)
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13350808.html
Copyright © 2011-2022 走看看