首页 > 代码库 > 根据sid或sqlID查询SQL

根据sid或sqlID查询SQL

根据sid查询已经执行过的sql

select sql_text from v$sqlarea a,v$session b where a.SQL_ID=b.PREV_SQL_ID and b.SID=&sid;
--------------------------------------------------------------------------------------

根据sid查询当前执行的sql

select sql_text from v$sqlarea where (hash_value,address)=(select sql_hash_value,sql_address from v$session where sid=&sid);

根据sid或sqlID查询SQL