以下包 dbms_application_info 对于检测您的查询非常有用。
在从应用层运行处理逻辑之前,设置模块/操作,以识别您的模块。
DBMS_APPLICATION_INFO.set_module(module_name => 'add_order',
action_name => 'processing orders');
之后,使用一个标记设置 client_info,该标记指示在运行 sql 之前正在进行的处理。
例如:
exec dbms_application_info.set_client_info('starting load from staging');
--Run the query
insert into dest_table select * from staging;
update dest_table set last_updated=sysdate;
exec dbms_application_info.set_client_info('updated the last_updated column');
delete from dest_table where order_value<0;
exec dbms_application_info.set_client_info('deleted -ve orders');
发生这种情况时,我们可以查看 v$session/v$sql 以了解当前处理的位置
SELECT sid,
serial#,
username,
osuser,
module,
action,
client_info
FROM v$session
WHERE module='add_order'
SELECT *
FROM v$sql
WHERE module='add_order'
看看链接
https://oracle-base.com/articles/8i/dbms_application_info