http://blog.csdn.net/liqfyiyi/article/details/7727641
http://www.askmaclean.com/archives/category/oracle/lock
http://database.51cto.com/art/201004/197299.htm
http://blog.csdn.net/dbseeker/article/details/17091023
http://blog.itpub.net/7194105/viewspace-704114/
http://hi.baidu.com/james_yulei/item/1b63fd0ea6bab71feafe388f
http://blog.itpub.net/11780477/viewspace-710115
http://www.docin.com/p-258161729.html
https://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1528515465282
https://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:6369740147072
DML操作引起的锁的类型和描述:
Operation Lock Mode LMODE Lock Description
------------------------- ---------- ------ -----------------
Select NULL 1 null
Select for update SS 2 sub share
Insert SX 3 sub exclusive
Update SX 3 sub exclusive
Delete SX 3 sub exclusive
Lock For Update SS 2 sub share
Lock Share S 4 share
Lock Exclusive X 6 exclusive
Lock Row Share SS 2 sub share
Lock Row Exclusive SX 3 sub exclusive
Lock Share Row Exclusive SSX 5 share/sub exclusive
Alter table X 6 exclusive
Drop table X 6 exclusive
Create Index S 4 share
Drop Index X 6 exclusive
Truncate table X 6 exclusive
Share Row Exclusive Table Lock (SRX)
This lock, also called a share-subexclusive table lock (SSX), is more restrictive
than a share table lock. Only one transaction at a time can acquire an SSX lock on a
given table. An SSX lock held by a transaction allows other transactions to query
the table (except for SELECT ... FOR UPDATE) but not to update the table.
LOCK TABLE xx IN SHARE ROW EXCLUSIVE MODE;
QL> select * from tv ;
T1
---------------------------------------
1
SQL> lock table tv in share mode;
Table(s) locked
SQL> update tv set t1=t1+2;
1 row updated
SQL> select sid,type,lmode from v$lock where type='TM';
SID TYPE LMODE
---------- ---- ----------
116 TM 5
0 - none
1 - null (NULL)
2 - row-S (SS)
3 - row-X (SX)
4 - share (S)
5 - S/Row-X (SSX)
6 - exclusive (X)
0 - 没有
1 - 空(NULL)
2 - 行子共享模式(SS)
3 - 行共享互斥模式(SX)
4 - 共享模式(S)
5 - 行子共享互斥模式
6 - 互斥模式(X)
DML操作引起的Oracle锁的类型和描述:
- Operation Lock Mode LMODE Lock Description
- ------------------------- ---------- ------ -----------------
- Select NULL 1 null
- Select for update SS 2 sub share
- Insert SX 3 sub exclusive
- Update SX 3 sub exclusive
- Delete SX 3 sub exclusive
- Lock For Update SS 2 sub share
- Lock Share S 4 share
- Lock Exclusive X 6 exclusive
- Lock Row Share SS 2 sub share
- Lock Row Exclusive SX 3 sub exclusive
- Lock Share Row Exclusive SSX 5 share/sub exclusive
- Alter table X 6 exclusive
- Drop table X 6 exclusive
- Create Index S 4 share
- Drop Index X 6 exclusive
- Truncate table X 6 exclusive
- -----------------------------------------------------------
Oracle锁的兼容性,YES表示锁可以共同存在,NO表示互斥。
- NULL SS SX S SSX X
- ------ ---- ---- ---- ----- ----
- NULL| YES YES YES YES YES YES
- SS | YES YES YES YES YES NO
- SX | YES YES YES NO NO NO
- S | YES YES NO YES NO NO
- SSX | YES YES NO NO NO NO
- X | YES NO NO NO NO NO