如何验证一句sql对特定行施行了行级锁?

帖子列表 发布于 2016/09/06 17:57
阅读 133
收藏 0
加载中
0
yintiefu
yintiefu
关闭事务 
#开启一个命令行窗口 1
set autocommit=off;
update t1 set email='test@test.com' where id=0;
#此处不提交

#开启第二个命令行窗口
set autocommit=off;
update t1 set email='test@test.com' where id=0;

show status like '%lock%';
+-------------------------------+---------+
| Variable_name                 | Value   |
+-------------------------------+---------+
| Com_lock_tables               | 0       |
| Com_unlock_tables             | 0       |
| Innodb_row_lock_current_waits | 1       | --这里
| Innodb_row_lock_time          | 0       |
| Innodb_row_lock_time_avg      | 0       |
| Innodb_row_lock_time_max      | 0       |
| Innodb_row_lock_waits         | 1       |
| Key_blocks_not_flushed        | 0       |
| Key_blocks_unused             | 14497   |
| Key_blocks_used               | 0       |
| Qcache_free_blocks            | 1       |
| Qcache_total_blocks           | 1       |
| Table_locks_immediate         | 2070991 |
| Table_locks_waited            | 2       |
+-------------------------------+---------+



返回顶部
顶部