首先打开两个窗口,可以考虑同时登陆同一个账号在两个窗口中:
窗口一:
执行:SCOTT@DBtest>select * from emp for update;
窗口二:
执行:SCOTT@DBtest>select * from dept for update;
接着窗口一:
执行:SCOTT@DBtest>update dept set deptno=60 where dname='guijian';
窗口二:SCOTT@DBtest>delete from emp where empno=7935;
执行:此时会产生死锁的场景,同时窗口一得会话牺牲掉,窗口二的会话继续等待执行:
SCOTT@DBtest>update dept set deptno=60 where dname='guijian';
update dept set deptno=60 where dname='guijian'
*
ERROR at line 1:
ORA-00060: deadlock detected while waiting for resource
若要解除锁定,需要某个会话提交当前事务。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/28612416/viewspace-765347/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/28612416/viewspace-765347/