oracle死锁模拟

用PLSQL Developer新建一个command window窗口,执行

update A g set g.status='9' where seq_id in(3407144);

--休眠8秒

exec dbms_lock.sleep(8);

update A g set g.status='9' where seq_id in(3407146);

commit;

新建一个command window窗口,执行

update A g set g.status='4' where seq_id in(3407146);

--休眠20秒

exec dbms_lock.sleep(20);

update A g set g.status='4' where seq_id in(3407144);

commit;

两个相互锁的sql执行,两个执行sql的事务是一起提交的,最后查数据,发现两条记录最后的状态是4,说明以最后提交的数据为准

猜你喜欢

转载自huang552.iteye.com/blog/2315481