declare
v_rowid varchar2(100);
begin
for i in (select c.data_object_id v_ob,
c.object_name v_obn,
row_wait_file# v_fno,
row_wait_block# v_bk,
row_wait_row# v_row,
username v_user
from gv$session a, Gv$lock b, dba_objects c
where a.sid = b.sid
and block > 0
and b.type in ('TX', 'TM')
and a.row_wait_obj# = c.object_id) loop
select dbms_rowid.rowid_create(1, i.v_ob, i.v_fno, i.v_bk, i.v_row)
into v_rowid
from dual;
dbms_output.put_line('select * from ' || i.v_user || '.' || i.v_obn ||
' where rowid=''' || v_rowid || ''';');
end loop;
end;
实验:
在一个会话窗口中 update a set id=2 where id=1;
在另外一个会话窗口 update a set id=2 where id=1;
可以通过构造ROWID查找到这行数据
打开serveroutput
执行上面匿名块 输出-----
select * from SCOTT.A where rowid='AAASIFAAEAAAACvAAG';
PL/SQL procedure successfully completed.
SQL> select * from SCOTT.A where rowid='AAASIFAAEAAAACvAAG';
ID
----------
1