---正在執行的
select a.username, a.sid,b.sql_text, b.sql_fulltext
from v$session a, v$sqlarea b
where a.sql_address = b.address
---執行過的
select b.sql_text,b.first_load_time,b.sql_fulltext
from v$sqlarea b
where b.first_load_time between '2009-10-15/09:24:47' and
'2009-10-15/09:24:47' order by b.first_load_time
(此方法好處可以檢視某一時間段執行過的sql,並且 sql_fulltext 包含了完整的 sql 語句)
其他select osuser,program,username,schemaname,b.cpu_time,status,b.sql_text
from v$session a left join v$sql b on a.sql_address=b.address and a.sql_hash_value=b.hash_value order by b.cpu_time desc
select address, sql_text, piece
from v$session, v$sqltext
where address = sql_address
-- and machine = < you machine name >
order by address, piece
查詢前十條效能差的sql.
select * from (select parsing_user_id,executions,sorts,
command_type,disk_reads,sql_text from v$sqlarea
order by disk_reads desc )where rownum<10 ;
檢視佔io較大的正在執行的session
select se.sid,se.serial#,pr.spid,se.username,se.status,
se.terminal,se.program,se.module,、se.sql_address,st.event,st.
p1text,si.physical_reads,
si.block_changes from v$session se,v$session_wait st,
v$sess_io si,v$process pr where st.sid=se.sid and st.
sid=si.sid and se.paddr=pr.addr and se.sid>6 and st.
wait_time=0 and st.event not like '%sql%' order by physical_reads desc
更多資訊請檢視it技術專欄
文章**於易賢網
查詢Oracle正在執行和執行過的SQL語句
正在執行的 select a.username,a.sid,b.sql text,b.sql fulltext from v session a,v sqlarea b where a.sql address b.address 執行過的 select b.sql text,b.first load...
查詢Oracle正在執行和執行過的SQL語句
正在執行的sql select a.username,a.sid,b.sql text,b.sql fulltext from v session a,v sqlarea b where a.sql address b.address 執行過的sql select b.sql text,b.firs...
查詢Oracle正在執行和執行過的SQL語句
正在執行的 selecta.username,a.sid,b.sql text,b.sql fulltext fromv session a,v sqlarea b wherea.sql address b.address 執行過的 selectb.sql text,b.first load tim...