lock table tablename in exclusive mode是在表级锁定,select * from tablename for update是行级锁定.比如:
session1:
SQL>lock table A in exclusive mode;
session2:
SQL>select * from A where 1=0 for update;
虽然是没有拿到任何数据,但还是进入了等待资源状态,因为lock table是锁住了整张表,所以对这张表的任何DML操作都会进入等待。
session1:
SQL>rollback;
SQL>select * from A for update;
session 2:
SQL>rollback;
SQL>select * from A where 1=0 for update这样就不会进入锁定状态。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/13387766/viewspace-478467/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/13387766/viewspace-478467/