select for update的两个选项
nowait
wait [time]
实验如下:
SessionB>select * from test_serializable for update;
A
----------
199
299
切换到另一个session
SQL> select * from test_serializable for update wait 180;
select * from test_serializable for update wait 180
*
ERROR at line 1:
ORA-30006: resource busy; acquire with WAIT timeout expired
由上可见,wait 180 等待180s后如果还是无法获取表的锁就报错
SQL> select * from test_serializable for update nowait;
select * from test_serializable for update nowait
*
ERROR at line 1:
ORA-00054: resource busy and acquire with NOWAIT specified
由上可见,no wait判断无法立即获取表的锁就报错
阅读(936) | 评论(0) | 转发(0) |