oracle中update和for update

update
对表中一行记录的修改,修改时会加锁。

select … for update
对满足条件的select结果集加锁。
如果结果集只要有一行记录被另一个session加锁,那么就会阻塞,直到那个session最后commit或者rollback之后执行。

select … for update nowait
如果满足条件的结果集只要有一行已经加锁了,不等待立即返回错误:
ORA-00054: resource busy and acquire with NOWAIT specified

for update和for update nowait加上的是一个行级排它锁。update加上的是一个共享锁,也就是说在update的时候可以对记录查询,但是查询出的结果可能就是update之前的值了。