select for update nowait 与 select for update 区别

来源:互联网 发布:大数据r语言 编辑:程序博客网 时间:2024/05/17 22:17

nowait的含义“不用等待,立即返回”,如果当前请求的资源被其他会话锁定时,会发生阻塞,nowait可以避免这一阻塞!!

 

使用select for update nowait:如果表被其他的用户进程锁了,则会立即返回“ORA-00054:资源正忙,但指定以NOWAIT方式获取资源”

 

使用select for update:如果表被其他的用户进程锁了,则会一直阻塞直到其他的用户进程释放了锁!其实,各数据库的处理机制是不一样的,例如:Mysql的话,会阻塞一段时间,接着抛出以下Error Code:1205异常:

Error Code : 1205Lock wait timeout exceeded; try restarting transaction(0 ms taken)


而,Oracle的话,会一直阻塞!

阅读全文
0 0
原创粉丝点击