表被锁住, 行级独占死锁时
- Select username,program,machine. sid. Serial# from v$session where username=’HR’ and terminal=’pts/3’; #TM是表级共享锁(), TX是行级独占锁
- Select * from v$session where blocking_session is not null;#查出受害者(阻塞等待的)sql_id
- Select * from v$sql where sql_id=’’;
- Select * from v$session where sid in (select blocking_session from v$session where blocking_session is not null);
- Alter system kill session ‘25,40275’ immediate; #kill 掉前面锁住的session
行级独占锁会导致锁表:解决方法是,update前先select
select 不会加锁, 加上for update nowait会上锁
select * from t08232 for update nowait; #查询是加锁,如果已经有锁,报错退出。
假如:遇到死锁时oracle会自动退出来。
死锁后,报oracle-00060的窗口输入commit 提交事务。