数据库锁的几种类型

1、共享锁(Shared lock)

  T1: select * from table (请想象它需要执行1个小时之久,后面的sql语句请都这么想象)

  T2: update table set column1=‘hello‘

2、更新锁(Update lock)

  T1: select * from table(updlock) (加更新锁)

    update table set column1=‘hello‘

  T2: select * from table(updlock)

    update table set column1=‘world‘

3、排他锁(独占锁,Exclusive Locks) 

  T1: update table set column1=‘hello‘ where id<1000

  T2: update table set column1=‘world‘ where id>1000

4、意向锁(Intent Locks)

  T1: select * from table (xlock) where id=10 --意思是对id=10这一行强加排他锁
  T2: select * from table (tablock) --意思是要加表级锁

5、计划锁(Schema Locks)

  alter table .... (加schema locks,称之为Schema modification (Sch-M) locks

相关文章