原本以为使用NOWAIT命令,可以使当前user忽略其它user对资源施加的锁直接执行,但是查看资料发现,并不是这样,NOWAIT只是检测所需资源是否被其它user锁定, 如果被锁定,无需等待,直接返回以下错误信息,并返回控制权限给当前user.
ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired
00054. 00000 - "resource busy and acquire with NOWAIT specified"
*Cause: Resource interested is busy.
*Action: Retry if necessary.
例子:
user 1: SELECT * from test_nick FOR UPDATE NOWAIT;--- 执行此语句,锁定表TEST_NICK
user 2: ALTER TABLE TEST_NICK ADD COLUMN4 VARCHAR(10); --执行此语句,user 2 会一直等待user 1释放表锁
user 3: LOCK TABLE TEST_NICK IN EXCLUSIVE MODE NOWAIT; --执行此语句, user 3不会等待user 1释放表锁,直接返回错误信息。