测试环境oracle11gR2
首先登录hr用户执行以下SQL
hr@ORCL112> update t set status='Y' where object_name like 'sys'; 已更新0行。
再另开一个session,用sys登录
当hr用户刚登录时,执行以下sql结果如下:
sys@ORCL112> select a.sid,a.type,a.lmode,a.request,a.block,trunc(a.id1/power(2,16)) rbs,bitand(a.id1,to_number('ffff','xxxx'))+0 s lot,a.id2 from v$lock a,v$session b where a.sid=b.sid and b.username='HR'; SID TY LMODE REQUEST BLOCK RBS SLOT ID2 ---------- -- ---------- ---------- ---------- ---------- ---------- ---------- 200 AE 4 0 0 0 100 0
当hr用户执行SQL时,执行以下sql结果如下:
sys@ORCL112> select a.sid,a.type,a.lmode,a.request,a.block,trunc(a.id1/power(2,16)) rbs,bitand(a.id1,to_number('ffff','xxxx'))+0 s lot,a.id2 from v$lock a,v$session b where a.sid=b.sid and b.username='HR'; SID TY LMODE REQUEST BLOCK RBS SLOT ID2 ---------- -- ---------- ---------- ---------- ---------- ---------- ---------- 200 AE 4 0 0 0 100 0 200 TM 3 0 0 1 11019 0 sys@ORCL112> select xidusn,xidslot,xidsqn,recursive from v$transaction; 未选定行
由此说明当更新一张表时,如果实际未更新到某条记录,则在v$lock只会产生TM锁,即表级锁
深入oracle,去透析oracle每个角落。
DBA、SQL开发技术人的集市,QQ高级群群号35448096