The dynamic performance view of the design is: V$session_event,v$session,v$sqlarea, the event can be found first in v$session_event, and then the SID is found through its dynamic performance view, which can be v$ Find the corresponding sql_id in the session, and then find the Sql_text in V$sqlarea by sql_id
View all the SQL statements for the event
SELECT DISTINCT S.sql_id,s.sid,se.event,se. Total_waits,sa.sql_text
From V$session s left join V$session_event se
On S.sid=se.sid
Left JOIN V$sqlarea SA
On s.sql_id=sa.sql_id
The Where SA. Sql_text is not NULL
ORDER BY se.total_waits Desc;
Query for the statement of a separate event event
Select S.sql_id,se.event,sa.sql_text
From V$session S, v$session_event se,v$sqlarea SA
where S.sid=se.sid and s.sql_id=sa.sql_id
and se.event=&event;
Sql> Select S.sql_id,se.event,sa.sql_text
From V$session S, v$session_event se,v$sqlarea SA
where S.sid=se.sid and s.sql_id=sa.sql_id
and se.event=&event; 2 3 4
Enter value for event: ' DB file sequential read '
Old 4:and Se.event=&event
New 4:and se.event= ' db file sequential read '
sql_id EVENT
------------- ----------------------------------------------------------------
Sql_text
--------------------------------------------------------------------------------
65VUZHM491WK9 db file Sequential read
DECLARE reason_id Dbms_server_alert. reason_id_t: = NULL; Resour
CE_ID number; Db_name Recent_resource_incarnations$.db_unique_name%ty
PE: =:d b_unique_name; Inst_name Recent_resource_incar
Nations$.instance_name%type: =: instance_name; event_id
Number: =: event_id; Event_time TIMESTAMP with time ZONE: =
To_timestamp_tz (: Event_time, ' YYY
Y-mm-dd HH24:MI:SS. FF tzh:tzm ', ' nls_calendar=
' Gregorian '); BEGIN case:reason_name when ' database_up ' then
sql_id EVENT
------------- ----------------------------------------------------------------
Sql_text
--------------------------------------------------------------------------------
reason_id: = Dbms_server_alert. RSN_FAN_DATABASE_UP; When ' Databa
Se_down ' then reason_id: = Dbms_server_alert. Rsn_fan_database_down;
When the ' instance_up ' then reason_id: = Dbms_server_alert. Rsn_fan_ins
TANCE_UP; When ' Instance_down ' then reason_id: = Dbms_server_al
Ert. Rsn_fan_instance_down; When '
View SQL statements with top 5 wait events