4for update锁表方式详解

Posted cl-learning

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了4for update锁表方式详解相关的知识,希望对你有一定的参考价值。

1、全表排他锁:

select * from employees for update;

 

2、选定行排他锁:

select * from employees where employees=100 for update;

 

3、两个表链接,只锁一个表的选定行:

select * from employees e,departments d where e.department_id=d.department_id and e.employee_id=100 for update of e.employee_id;

 

4、采用排他锁时选择不等待(这个表被别人占用时立马报错,结束等待):

select * from employees for update nowait;

 

5、采用排他锁时,指定等待多少秒:

单位默认为:秒

select * from employees where employee_id=100 wait 5;

 

以上是关于4for update锁表方式详解的主要内容,如果未能解决你的问题,请参考以下文章