oracle数据库执行sql语句报错(ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired)

oracle数据库执行sql语句报错(ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired)

如下图:

对people2表进行drop操作

oracle数据库执行sql语句报错(ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired)

之所以会报这个错误是因为,如下图:

因为执行了对people2表的insert的sql语句,既没commit提交,也没rollback回滚

oracle数据库执行sql语句报错(ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired)

所以,在客户端A,写上commit提交或者rollback回滚就可以解决这个问题

oracle数据库执行sql语句报错(ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired)

当然了,这是我在我自己电脑上,我自己开了2个客户端,所以我知道是因为我另一个客户端占用了这个表的资源,一直没有释放掉,所以,我可以通过在客户端A提交或者回滚来解决这个问题

如果是其他人远程在操作people2表,对方一直没提交也没回滚,一直没释放掉资源,而我又对这张表进行了drop操作,报了ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired这个错误,该怎么办呢?

第1种办法

大家可以重启一下数据库服务,当然了,我不建议这样做,因为大家都还要用数据库,所以千万别重启,如果是测试环境,那就没所谓了!

第2种办法

在客户端B执行如下语句

select l.session_id,o.owner,o.object_name from
v$locked_object l,dba_objects o where l.object_id=o.object_id;

oracle数据库执行sql语句报错(ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired)

在客户端B执行以下sql语句,把sid改掉就行了

SELECT sid, serial#, username, oSUSEr,
terminal,program ,action, prev_exec_start
FROM v$session where sid = 70;

oracle数据库执行sql语句报错(ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired)

根据上面查出来的 SID,SERIAL# 杀掉占用资源

注意:一定要用客户端B杀,用客户端A杀是杀不掉的,因为杀的是客户端A自己

oracle数据库执行sql语句报错(ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired)

一定要用客户端B杀,如下:

oracle数据库执行sql语句报错(ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired)

此时,再在客户端Bpeople2表进行drop操作不会报ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired这个错误了