Hunter的大杂烩 技术学习笔记

2009-07-01

mysql 事务测试

Filed under: 技术话题 — hunter @ 6:48 pm

mysql> show variables like “tx%”;
+—————+—————–+
| Variable_name | Value           |
+—————+—————–+
| tx_isolation  | REPEATABLE-READ |
+—————+—————–+
1 row in set (0.00 sec)
 

            A                          B
      select A = 100
      start transaction               
                                  update  record A set 111
      select A = 111
                                  update  record A set 122
      select A = 111
      update A = 333
                           select A = 122
                                  update  record A set 111
                                  block
      commit
                                  unblock
                           select A = 111


==============================================================

      select A = 100
      select B = 100
      select C = 100
      start transaction               
                                  update  record A set 122
      select A = 100
      select B = 100
      select C = 100
      select A for update = 122
                                  update  record A set 122
                                  block
      commit
                                  unblock
                           select A = 122

==============================================================
      select A = 100
      select B = 100
      select C = 100
      start transaction               
      update A = 333 //非索引
                                  update  record B set 122
                                  block //全表被锁
      commit
                                  unblock
==============================================================
      select A = 100
      select B = 100
      select C = 100
      start transaction               
      update A = 333 //索引
                                  update  record B set 122 //记录级锁
                           select B = 122
                                  insert  D=101
      select * for update
      a/b/c/d
                                  insert  E=101
                                  block
      commit

 

 

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress